Submission #242203

#TimeUsernameProblemLanguageResultExecution timeMemory
242203dwscWorst Reporter 3 (JOI18_worst_reporter3)C++14
0 / 100
649 ms7672 KiB
#include <bits/stdc++.h> #define int long long using namespace std; main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,q; cin >> n >> q; int arr[n+1]; arr[0] = 1; for (int i = 1; i <= n; i++){ cin >> arr[i]; arr[i] = ((arr[i]+arr[i-1]-1)/arr[i-1])*arr[i-1]; //cout << arr[i] << "\n"; } for (int i = 0; i < q; i++){ int l,r,t; cin >> t>> l >> r; int lo1 = 0,hi1 = n+1; int ans1 = -1; while (lo1 != hi1){ int m = (lo1+hi1)/2; int travel = (t/arr[m])*arr[m]; int newcoord = -m+travel; if (newcoord <= r){ hi1 = m; ans1 = m; } else{ lo1 = m+1; } } int lo2 = 0,hi2 = n+1; int ans2 = -1; while (lo2 != hi2){ int m = (lo2+hi2)/2; int travel = (t/arr[m])*arr[m]; int newcoord = -m+travel; if (newcoord >= l){ lo2 = m+1; ans2 = m; } else{ hi2 = m; } } // cout << ans1 << " " << ans2 << "hi\n"; if (ans1 < 0 || ans2 < 0) cout << 0 << "\n"; cout << max(ans2-ans1+1,0LL) << "\n"; } }

Compilation message (stderr)

worst_reporter3.cpp:4:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...