Submission #1023362

#TimeUsernameProblemLanguageResultExecution timeMemory
1023362ShadxwedFountain (eJOI20_fountain)C11
0 / 100
1583 ms4796 KiB
#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]); printf("%d %d\n", 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)

fountain.c: In function 'main':
fountain.c:6:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d %d", &n, &q);
      |     ^~~~~~~~~~~~~~~~~~~~~~
fountain.c:10:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%d %d", &d[i], &v[i]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
fountain.c:15:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d %d", &q1, &q2);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...