Submission #990634

#TimeUsernameProblemLanguageResultExecution timeMemory
990634_Knyaz_Fountain (eJOI20_fountain)C++17
30 / 100
1546 ms3604 KiB
#include<bits/stdc++.h> using namespace std; const int INF = 1e9+1; void in(){ freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } vector<pair<int, int>> Fountain; int main() { //in(); int N, Q; cin >> N >> Q; for(int i = 0; i < N; i++){ int Di, Ci; cin >> Di >> Ci; Fountain.push_back(make_pair(Di, Ci)); } int Ri, Vi, Mn; for(int i = 0; i < Q; i++){ cin >> Ri >> Vi; Mn = Fountain[Ri - 1].first - 1; for(int j = Ri - 1; j < N; j++){ if(Fountain[j].second >= Vi && Fountain[j].first > Mn){ cout << j + 1 << '\n'; Vi = 0; break; } else if(Fountain[j].first > Mn){ Vi -= Fountain[j].second; Mn = Fountain[j].first; } } if(Vi > 0) cout << 0 << '\n'; } }

Compilation message (stderr)

fountain.cpp: In function 'void in()':
fountain.cpp:5:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
fountain.cpp:6:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...