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;
}

curl-programming-lang 1.0.2

Introduction to curl-programming-lang 1.0.2 The open-source developer ecosystem continues to...

Why Everyone is Obsessed with the Under Desk Foot Rest

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

Why Everyone is Obsessed with the Rug Gripper Pads

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

curl-programming-lang 1.0.2

Introduction to curl-programming-lang 1.0.2 The open-source developer ecosystem continues to thrive with the introduction of innovative tools designed to simplify software creation. A fascinating new...

Why Everyone is Obsessed with the Blind Spot Mirrors

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

Why Everyone is Obsessed with the Magnetic Spice Rack

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

Why Everyone is Obsessed with the Webcam Cover Slide

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

Why Everyone is Obsessed with the Magnetic Cabinet Locks

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

Betty Gilpin Says She Was ‘Freaked Out’ Over Prosthetic Genitalia for ‘Office Romance’ Birth Scene

Acclaimed actress Betty Gilpin is known for her fearless performances, but a specific prop on the set of her latest film pushed her well...

Why Everyone is Obsessed with the Microfiber Hair Towel

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