Submission #624456

#TimeUsernameProblemLanguageResultExecution timeMemory
624456radalWorst Reporter 3 (JOI18_worst_reporter3)C++17
19 / 100
205 ms17496 KiB
#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,lg = 20; 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 po[N/500+10][N/500+10]; int main(){ ios :: sync_with_stdio(0); cin.tie(0); int n,q; cin >> n >> q; bool fl = 1; rep(i,1,n+1){ cin >> d[i]; if (d[i] != 1) fl = 0; } if (fl){ while (q--){ int t,l,r; cin >> t >> l >> r; if (t < l || t-n > r){ cout << 0 << endl; continue; } cout << min(t,r)-max(l,t-n)+1 << endl; } return 0; } rep(i,0,1001) po[0][i] = i; rep(i,1,n+1) po[i][0] = -i; rep(j,1,1001){ rep(i,1,n+1){ if (po[i-1][j]-po[i][j-1] >= d[i]+1) po[i][j] = po[i-1][j]-1; else po[i][j] = po[i][j-1]; } } while (q--){ int t,l,r; cin >> t >> l >> r; int ans = 0; rep(i,0,n+1) if (po[i][t] >= l && po[i][t] <= r) ans++; cout << ans << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...