Submission #841808

#TimeUsernameProblemLanguageResultExecution timeMemory
841808konberFountain (eJOI20_fountain)C++14
30 / 100
14 ms2404 KiB
#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 (stderr)

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);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...