답안 #1023366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023366 2024-07-14T17:06:52 Z Shadxwed Fountain (eJOI20_fountain) C
30 / 100
1500 ms 1432 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]);
    }
    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:14:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d %d", &q1, &q2);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1592 ms 1432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Execution timed out 1592 ms 1432 KB Time limit exceeded
9 Halted 0 ms 0 KB -