답안 #841808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
841808 2023-09-02T06:46:22 Z konber Fountain (eJOI20_fountain) C++14
30 / 100
14 ms 2404 KB
#include <iostream>

using namespace std;

int main()
{
    //freopen("data.in", "r", stdin);
    int N, Q, r, c, last, i;
    scanf("%d%d", &N, &Q);
    int d[N+1], v[N+1];
    for(int j=1; j <= N; j++) scanf("%d%d", &d[j], &v[j]);

    if (N > 1000 || Q > 2000) return 0;
    while(Q--){
        scanf("%d%d", &r, &c);
        last = r;
        c -= v[r];
        for(i=r; i <= N && c > 0; i++){
            if(d[i] > d[last]){
                c -= v[i];
                last = i;
            }
        }
        printf("%d\n", (c <= 0) ? last : 0);
    }
}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d", &N, &Q);
      |     ~~~~~^~~~~~~~~~~~~~~~
fountain.cpp:11:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(int j=1; j <= N; j++) scanf("%d%d", &d[j], &v[j]);
      |                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~
fountain.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d%d", &r, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 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 Incorrect 14 ms 2404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 14 ms 2404 KB Output isn't correct
9 Halted 0 ms 0 KB -