Submission #1039779

#TimeUsernameProblemLanguageResultExecution timeMemory
1039779AndreyWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
339 ms25428 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n,q,a,b,t; cin >> n >> q; vector<long long> haha(n+1,1); for(long long i = 1; i <= n; i++) { cin >> haha[i]; haha[i] = haha[i-1]*((haha[i]+haha[i-1]-1)/haha[i-1]); haha[i] = min(haha[i],(long long)INT_MAX); } for(long long i = 0; i < q; i++) { cin >> t >> a >> b; long long c = a,ans = 0; if(t >= c) { long long l = 0,r = haha.size()-1; while(l < r) { long long 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) { long long l = 0,r = haha.size()-1; while(l < r) { long long 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...