Codeforces Round #379 (Div. 2), problem: (C) Anton and Making Potions Solution in C

Hey guys I just tried the Anton and Making Potions problem , hope you might like my solution feel free to comment better solution .

#include

#define N 200000

struct type2 {
int c, d;
} yy[N];

int binsearch(struct type2 *yy, int x, int k) {
int l = -1, r = k;

while (r – l > 1) {
int m = (l + r) / 2;

if (yy[m].d > x)
r = m;
else
l = m;
}
return l;
}

int main() {
int i, n, m, k, x, s;
long long min;
static int aa[N], bb[N];

scanf(“%d%d%d%d%d”, &n, &m, &k, &x, &s);
for (i = 0; i < m; i++) scanf("%d", &aa[i]); for (i = 0; i < m; i++) scanf("%d", &bb[i]); for (i = 0; i < k; i++) scanf("%d", &yy[i].c); for (i = 0; i < k; i++) scanf("%d", &yy[i].d); for (i = 0; i < k; i++) if (yy[i].d > s)
break;
i–;
if (i >= 0)
min = (long long) (n – yy[i].c) * x;
else
min = (long long) n * x;
for (i = 0; i < m; i++) { int j; if (bb[i] > s)
continue;
j = binsearch(yy, s – bb[i], k);
if (j >= 0) {
long long t = (long long) aa[i] * (n – yy[j].c);

if (min > t)
min = t;
} else {
long long t = (long long) aa[i] * n;

if (min > t)
min = t;
}
}
printf(“%lld\n”, min);
return 0;
}

A Sea Cucumber’s Amputated...

The Mystery of the Undying Sea Cucumber TissueNature never...

Why Everyone is Obsessed with the Shower Phone Holder Case

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

Why Everyone is Obsessed with the Universal Travel Adapter

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

Why Everyone is Obsessed with the Bamboo Cutting Board Set

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

A Sea Cucumber’s Amputated Tissue Refuses To Die. Could It Live Forever?

The Mystery of the Undying Sea Cucumber TissueNature never ceases to amaze, and the latest discovery in marine biology has left scientists questioning the...

Why Everyone is Obsessed with the Car Seat Gap Organizer

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

Why Everyone is Obsessed with the Reusable Lint Roller

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

DraftKings: Prediction Markets Are Eating This Company’s Lunch (Rating Downgrade)

The online sports betting landscape is shifting rapidly, and industry giant DraftKings (DKNG) is finding itself in increasingly turbulent waters. Once the undisputed darling...

Why Everyone is Obsessed with the Universal Charging Cable

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

Why Everyone is Obsessed with the Fridge Odor Eliminator

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...