답안 #972325

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972325 2024-04-30T10:54:03 Z LCJLY Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
28 ms 17488 KB
#include <bits/stdc++.h>
using namespace std;
	
#define int long long 
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<long long,long long>pii;
typedef pair<int,pii>pi2;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
 
void solve(){
	int n,q;
	cin >> n >> q;
	int arr[n];
	int pos[n];
	for(int x=1;x<=n;x++){
		cin >> arr[x];
		pos[x]=-x;
	}
	pos[0]=0;
	
	vector<pair<pii,int>>que[1005];
	int temp,temp2,temp3;
	for(int x=0;x<q;x++){
		cin >> temp >> temp2 >> temp3;
		que[temp].push_back({{temp2,temp3},x});
	}
	int ans[1005];
	
	for(int x=1;x<1005;x++){
		pos[0]++;
		for(int y=1;y<=n;y++){
			if(abs(pos[y]-pos[y-1])>=arr[y]+1){
				pos[y]=pos[y-1]-1;
			}
		}
		for(auto it:que[x]){
			int l=it.first.first;
			int r=it.first.second;
			int index=it.second;
			reverse(pos,pos+n+1);
			int hold=lower_bound(pos,pos+1+n,l)-(pos+1);
			int hold2=upper_bound(pos,pos+1+n,r)-(pos+1);
			reverse(pos,pos+n+1);
			ans[index]=hold2-hold;
		}
		//for(int y=0;y<=n;y++){
			//cout << pos[y] << " ";
		//}
		//cout << endl;
	}
	
	for(int x=0;x<q;x++){
		cout << ans[x] << "\n";
	}
}
 
int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//freopen("in.txt","r",stdin);
	//cin >> t;
	while(t--){
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 28 ms 17488 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 28 ms 17488 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -