# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124410 | naderjemel | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 60 ms | 12724 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define INF 1e9
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
vi ds;
int pos[1005][1005];
int main(){
int n,q;
scanf("%d%d",&n,&q);
ds.pb(1);
for(int i=1;i<=n;i++){
int h; scanf("%d",&h);
ds.pb(h);
}
for(int i=0;i<=1000;i++){
pos[i][0]=0-i;
}
for(int t=1;t<=1000;t++){
pos[0][t]=t;
for(int i=1;i<=n;i++){
if(pos[i-1][t]-pos[i][t-1]>=ds[i]+1){
pos[i][t]=pos[i-1][t]-1;
}
else pos[i][t]=pos[i][t-1];
//if(i==2 && t<=250) printf("at T=%d. %d is at position %d.\n", t,i,pos[i][t]);
}
}
vi jump;
for(int i=0;i<n;i++){
for(int t=1;t<=1000;t++){
if(pos[i][t]!=pos[i][t-1]){
jump.pb(pos[i][t]-pos[i][t-1]);
break;
}
}
}
while(q--){
int t,l,r; scanf("%d%d%d",&t,&l,&r);
int rs=0;
for(int i=0;i<=n;i++){
if(pos[i][t]>=l && pos[i][t]<=r){
//printf("%d\n", pos[i][t]);
rs++;
}
}
printf("%d\n", rs);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |