Submission #635254

#TimeUsernameProblemLanguageResultExecution timeMemory
635254ParsaEsWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
497 ms25320 KiB
//InTheNameOfGOD //PRS;) #pragma GCC optimize("unroll-loops", "O2", "Ofast", "O3") #pragma GCC target("avx2", "sse", "sse2") #include<bits/stdc++.h> #define Fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define rep(i, l, r) for(ii i = l; i < r; i++) #define max(x, y) (x > y ? x : y) typedef long long ii; using namespace std; constexpr int xn = 5e5 + 5; ii d[xn]; int main() { Fast; ii n, q; cin >> n >> q; rep(i, 0, n) cin >> d[i]; rep(i, 1, n) d[i] = ((d[i] + d[i - 1] - 1) / d[i - 1]) * d[i - 1]; while(q--) { ii t, l, r, p1 = 0, p2 = n, p3 = 0, p4 = n; cin >> t >> l >> r; while(p1 < p2) { ii m = p1 + p2 >> 1; if((t / d[m]) * d[m] - m - 1 < l) p2 = m; else p1 = m + 1; } while(p3 < p4) { ii m = p3 + p4 >> 1; if((t / d[m]) * d[m] - m - 1 > r) p3 = m + 1; else p4 = m; } ii ans = max(0, p1 - p4); if(l <= t && t <= r) ans++; cout << ans << '\n'; } }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:26:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |    ii m = p1 + p2 >> 1;
      |           ~~~^~~~
worst_reporter3.cpp:32:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |    ii m = p3 + p4 >> 1;
      |           ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...