Submission #1024556

#TimeUsernameProblemLanguageResultExecution timeMemory
1024556vjudge1Fountain (eJOI20_fountain)C++17
30 / 100
72 ms2132 KiB
#include <bits/stdc++.h> using namespace std; int vkupno[100005]; int n, q; int binarno(int rezervoar, int voda) { int l=rezervoar-1, r=n+1; while (l+1<r) { int mid=(l+r)/2; if (vkupno[mid]-vkupno[rezervoar-1]>=voda) r=mid; else l=mid; } return r; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> q; int dijametar[n+1], kapacitet[n+1]; for (int i=1;i<=n;i++) cin >> dijametar[i] >> kapacitet[i]; vkupno[0]=0; for (int i=1;i<=n;i++) vkupno[i]=vkupno[i-1]+kapacitet[i]; vkupno[n+1]=INT_MAX; while (q--) { int r, v; cin >> r >> v; int rez=binarno(r, v); if (rez==n+1) cout << 0 << '\n'; else cout << rez << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...