Submission #469258

#TimeUsernameProblemLanguageResultExecution timeMemory
469258keta_tsimakuridzeWorst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
94 ms10948 KiB
#include<bits/stdc++.h> #define f first #define s second #define int long long #define pii pair<int,int> #define endl "\n" using namespace std; const int N = 2e5 + 5, inf = 1e15 + 7; // ! int t[N],v[N],d[N],n,q,L; int get(int x,int T) { int l = 0, r = L,cnt = 0; while(l <= r) { int mid = (l + r) / 2; if(-mid + T / t[mid] * v[mid] >= x) cnt = mid + 1, l = mid + 1; else r = mid - 1; } return cnt; } main(){ int q; cin >> n >> q; for(int i = 1; i <= n; i++) { cin >> d[i]; } t[0] = v[0] = 1; L = 0; for(int i = 1; i <= n; i++) { t[i] = t[i - 1] * ((d[i] + v[i - 1] - 1) / v[i - 1]); if(t[i] > inf) { break; } L = i; v[i] = (d[i] + v[i - 1] - 1 ) / v[i - 1] * v[i - 1]; } while(q--) { int l,r,t; cin >>t >> l >> r; cout << get(l,t) - get(r + 1,t) << endl; } }

Compilation message (stderr)

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