Submission #1039775

#TimeUsernameProblemLanguageResultExecution timeMemory
1039775AndreyWorst Reporter 3 (JOI18_worst_reporter3)C++14
19 / 100
335 ms20820 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,q,a,b,t; cin >> n >> q; vector<int> haha(n+1,1); for(int i = 1; i <= n; i++) { cin >> haha[i]; haha[i] = haha[i-1]*((haha[i]+haha[i-1]-1)/haha[i-1]); } for(int i = 0; i < q; i++) { cin >> t >> a >> b; int c = a,ans = 0; if(t >= c) { int l = 0,r = haha.size()-1; while(l < r) { int mid = (l+r+1)/2; if(-mid+haha[mid]*(t/haha[mid]) >= c) { l = mid; } else { r = mid-1; } } ans+=l+1; } c = b+1; if(t >= c) { int l = 0,r = haha.size()-1; while(l < r) { int mid = (l+r+1)/2; if(-mid+haha[mid]*(t/haha[mid]) >= c) { l = mid; } else { r = mid-1; } } ans-=l+1; } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...