Submission #463273

#TimeUsernameProblemLanguageResultExecution timeMemory
463273Em1LFountain (eJOI20_fountain)C++14
30 / 100
1597 ms1384 KiB
#include <bits/stdc++.h> using namespace std; void fastIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { int n, q, x, y; cin >> n >> q; vector < pair <int, int> > v; while (n--) { cin >> x >> y; v.push_back(make_pair(x, y)); } while (q--) { cin >> x >> y; int prev = x - 1; for (int i = x - 1; i < v.size(); i++) { if (y <= 0) { cout << i << '\n'; break; } if (prev == i or v[prev].first < v[i].first) { y -= v[i].second; prev = i; } } if (y > 0) cout << '0' << '\n'; } }

Compilation message (stderr)

fountain.cpp: In function 'int main()':
fountain.cpp:34:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for (int i = x - 1; i < v.size(); i++)
      |                             ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...