Submission #624584

#TimeUsernameProblemLanguageResultExecution timeMemory
624584radalWorst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
539 ms25368 KiB
//why I missed it #include <bits/stdc++.h> #pragma GCC target("sse,sse2,avx2") #pragma GCC optimize("unroll-loops,O2") #define rep(i,l,r) for (int i = l; i < r; i++) #define repr(i,r,l) for (int i = r; i >= l; i--) #define X first #define Y second #define all(x) (x).begin() , (x).end() #define pb push_back #define endl '\n' #define debug(x) cerr << #x << " : " << x << endl; using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pll; constexpr ll N = 5e5+10,mod = 998244353,inf = 1e9+10; inline int mkay(int a,int b){ if (a+b >= mod) return a+b-mod; if (a+b < 0) return a+b+mod; return a+b; } inline int poww(int a,int k){ if (k < 0) return 0; int z = 1; while (k){ if (k&1) z = 1ll*z*a%mod; a = 1ll*a*a%mod; k /= 2; } return z; } int d[N]; int a[N]; int main(){ ios :: sync_with_stdio(0); cin.tie(0); int n,q; cin >> n >> q; a[0] = 1; rep(i,1,n+1){ cin >> d[i]; int cnt = (d[i]+a[i-1]-1)/a[i-1]; ll cal1 = 1ll*a[i-1]*cnt; if (cal1 < inf) a[i] = cal1; else a[i] = inf; } while(q--){ int t,x,y; cin >> t >> x >> y; int l = -1,r = n+1,m; while(r-l > 1){ m = (l+r) >> 1; int cnt = t/a[m]; ll po = 1ll*cnt*a[m]-m; if (po > y) l = m; else r = m; } int ans = -r; x--; l = -1; r = n+1; while(r-l > 1){ m = (l+r) >> 1; int cnt = t/a[m]; ll po = 1ll*cnt*a[m]-m; if (po > x) l = m; else r = m; } ans += r; cout << ans << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...