답안 #124410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124410 2019-07-03T09:55:10 Z naderjemel Worst Reporter 3 (JOI18_worst_reporter3) C++17
12 / 100
60 ms 12724 KB
#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

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);
              ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 60 ms 12724 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 4216 KB Output is correct
2 Correct 12 ms 4216 KB Output is correct
3 Correct 12 ms 4216 KB Output is correct
4 Correct 11 ms 4216 KB Output is correct
5 Correct 12 ms 4344 KB Output is correct
6 Correct 11 ms 4216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 60 ms 12724 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -