# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023366 | Shadxwed | Fountain (eJOI20_fountain) | C11 | 1592 ms | 1432 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <stdlib.h>
int main() {
int n, q;
scanf("%d %d", &n, &q);
int *d = malloc(n*sizeof(int));
int *v = malloc(n*sizeof(int));
for(int i = 0; i < n; i++) {
scanf("%d %d", &d[i], &v[i]);
}
int q1, q2, prev;
for(int i = 0; i < q; i++) {
scanf("%d %d", &q1, &q2);
prev = -1;
for(int j = q1-1; j < n; j++) {
if(d[j] > prev) {
q2 -= v[j];
prev = d[j];
if(q2 <= 0) {
printf("%d\n", j+1);
break;
}
}
}
if(q2 > 0) {
printf("0\n");
}
}
free(d);
free(v);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |