Submission #1023362

# Submission time Handle Problem Language Result Execution time Memory
1023362 2024-07-14T16:58:18 Z Shadxwed Fountain (eJOI20_fountain) C
0 / 100
1500 ms 4796 KB
#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

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 time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1583 ms 4796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -