Submission #576527

#TimeUsernameProblemLanguageResultExecution timeMemory
576527JassarFountain (eJOI20_fountain)C++14
0 / 100
1589 ms3948 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll n,q; cin >> n >> q; vector<pair<ll , ll>> v; stack<ll> s; ll p[n]; for (ll i=0; n>i; i++) { p[i] = 0; } ll sum[n]; for (ll i=0; n>i; i++) { ll a,b; cin >> a >> b; v.push_back({a , b}); sum[i] = v[i].second; if (i > 0) sum[i] += sum[i-1]; } while (q--) { ll a,b; cin >> a >> b; a--; for (ll i=0; n>i; i++) { if (a == 0 && sum[i] >= b) { cout << i + 1 << endl; a = -3; break; } if (a > 0 && sum[i] - sum[a - 1] >= b) { cout << i + 1 << endl; a = -3; break; } } if (a != -3) { cout << 0 << endl; } } return 0; }

Compilation message (stderr)

fountain.cpp: In function 'int main()':
fountain.cpp:13:5: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   13 |  ll p[n];
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...