Submission #637871

#TimeUsernameProblemLanguageResultExecution timeMemory
637871kidesoFountain (eJOI20_fountain)C++17
60 / 100
1566 ms256756 KiB
#include <iostream> #include <queue> #include <algorithm> using namespace std; struct P1{ int start, extra; }; struct P{ int volume, index; }; vector<vector<P> > routes(1, vector<P> ()); int N, Q, v, d; bool operator < (const P &a, int val){ return a.volume < val; } int main(){ cin >> N >> Q; vector<P1> x(N + 1, {0, 0}); vector<int> diameters(N + 1, 0); cin >> diameters[1] >> v; x[1] = {1, 0}; routes.push_back(vector<P>()); routes[1].push_back({v, 1}); for(int i = 2; i <= N; ++i){ cin >> diameters[i] >> v; bool ok = false; for(int j = 1; j < routes.size(); ++j){ auto [V, s] = routes[j].back(); if(diameters[s] < diameters[i]){ ok = true; if(x[i].start == 0) x[i] = {j, V}; V += v; routes[j].push_back({V, i}); } } if(!ok){ int p = routes.size(); x[i] = {p, 0}; routes.push_back(vector<P>(1, {v, i})); } } int from, volume; while(Q--){ cin >> from >> volume; volume += x[from].extra; from = x[from].start; auto it = lower_bound(routes[from].begin(), routes[from].end(), volume); cout << (it == routes[from].end() ? 0 : it -> index) << '\n'; } return 0; }

Compilation message (stderr)

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