답안 #595544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595544 2022-07-13T20:04:21 Z UncoolAnon 케이크 (CEOI14_cake) C++14
46.6667 / 100
2000 ms 14556 KB
#include <bits/stdc++.h> 

#define pii pair<int,int> 
#define F first 
#define S second 
#define mp make_pair 

using namespace std; 
int n,si; 
set<pii> order; 
vector<int> a; 
int query(int t){
	int l=si,r=si;
	while(t<l||t>r){
		if(l==0) ++r;
		else if(r==n-1) --l; 
		else if(a[l-1]<a[r+1]) --l; 
		else ++r; 
	}
	return r-l; 
}
void update(int i,int e){
	order.erase(mp(-a[i],i)); 
	vector<int> hold; 
	int mn=-(order.begin()->first)+1; 
	while(e--!=1){
		hold.push_back(order.begin()->second); 
		order.erase(order.begin()); 
	}
	for(int&x:hold){
		++a[x];
		mn=min(mn,a[x]-1); 
		order.insert(mp(-a[x],x)); 
	}
	order.insert(mp(-mn,i)); 
	a[i]=mn; 
	return ; 
}
int main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(nullptr); 
	cin>>n>>si; --si; a.resize(n); 
	for(int i=0;i<n;++i){
		cin>>a[i];
		order.insert(mp(-a[i],i)); 
	}
	int q; 
	cin>>q; 
	while(q--){
		char x;
		cin>>x ;
		if(x=='F'){
			int y; 
			cin>>y; --y;
			cout<<query(y)<<'\n'; 
		}
		else{
			int i,e; 
			cin>>i>>e; --i; 
			update(i,e); 
		}
	}
	return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 6 ms 336 KB Output is correct
5 Correct 43 ms 964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 2168 KB Output is correct
2 Correct 202 ms 2108 KB Output is correct
3 Correct 231 ms 2104 KB Output is correct
4 Correct 138 ms 2212 KB Output is correct
5 Correct 348 ms 2880 KB Output is correct
6 Correct 311 ms 2868 KB Output is correct
7 Correct 241 ms 2980 KB Output is correct
8 Correct 191 ms 3064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 6572 KB Time limit exceeded
2 Execution timed out 2051 ms 6780 KB Time limit exceeded
3 Execution timed out 2061 ms 6952 KB Time limit exceeded
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2075 ms 14388 KB Time limit exceeded
6 Execution timed out 2071 ms 14440 KB Time limit exceeded
7 Execution timed out 2071 ms 14516 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 928 KB Output is correct
2 Correct 108 ms 1088 KB Output is correct
3 Correct 1323 ms 3988 KB Output is correct
4 Correct 1323 ms 3980 KB Output is correct
5 Correct 194 ms 1832 KB Output is correct
6 Execution timed out 2078 ms 5644 KB Time limit exceeded
7 Correct 644 ms 2720 KB Output is correct
8 Correct 334 ms 6728 KB Output is correct
9 Execution timed out 2077 ms 14556 KB Time limit exceeded
10 Correct 637 ms 2928 KB Output is correct
11 Execution timed out 2013 ms 3708 KB Time limit exceeded
12 Execution timed out 2070 ms 11900 KB Time limit exceeded
13 Execution timed out 2045 ms 14356 KB Time limit exceeded