Submission #124652

#TimeUsernameProblemLanguageResultExecution timeMemory
124652youssefbou62Worst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
823 ms13068 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define allarr(a) a , a + n #define ll long long #define ull unsigned long long #define pb push_back #define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL) typedef pair<int, int> pi; typedef pair<ll,ll> pll; typedef pair<int,pi> trp ; typedef vector<pi> vpi; typedef vector<pll> vpll ; ll _abs (ll x ) { return (x>0?x:-x); } const int N =500005 ; int D[N] ; int place [1005][1005] ; int main(){ fastio ; int n , q ; cin >> n >> q ; for(int i = 0 ; i <= n ;i++ ){ if( i ) cin >> D[i] ; place[0][i]= -i ; } for( int t = 1 ; t <= 1000 ; t++ ){ for (int p = 0 ; p <= n ; p++ ){ if(t) place[t][p] = place[t-1][p] ; if( !p )place[t][p]++ ; if( p && -place[t][p]+place[t][p-1] > D[p]){ place[t][p] = place[t][p-1] - 1 ; } // reverse ( place[t] , place[t] + n + 1 ) ; } } int t , l , r ; // for(int t = 0 ; t < 3 ; t++ ){ // for(int i= 0 ; i<=n;i++){ // cout << place[t][i]<< " " ; // } // cout << endl; // } while ( q-- ){ cin >> t >> l >> r ; int ans =0 ; for(int i = 0 ; i <= n ; i++ ){ // cout << place[t][i]<<" " ; if( place[t][i] >= l && place[t][i] <= r ) ans ++ ; } cout << ans << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...