Submission #124410

#TimeUsernameProblemLanguageResultExecution timeMemory
124410naderjemelWorst Reporter 3 (JOI18_worst_reporter3)C++17
12 / 100
60 ms12724 KiB
#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)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&q);
  ~~~~~^~~~~~~~~~~~~~
worst_reporter3.cpp:20:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int h; scanf("%d",&h);
          ~~~~~^~~~~~~~~
worst_reporter3.cpp:47:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int t,l,r; scanf("%d%d%d",&t,&l,&r);
              ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...