답안 #595536

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595536 2022-07-13T20:00:40 Z UncoolAnon 케이크 (CEOI14_cake) C++14
0 / 100
4 ms 596 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; 
	while(e--){
		hold.push_back(order.begin()->second); 
		order.erase(order.begin()); 
	}
	int mn=1e9; 
	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); 
	freopen("in.txt","r",stdin); 
	freopen("out.txt","w",stdout); 
	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; 
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:42:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |  freopen("in.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
cake.cpp:43:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  freopen("out.txt","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 596 KB Execution killed with signal 11
2 Runtime error 2 ms 596 KB Execution killed with signal 11
3 Runtime error 3 ms 596 KB Execution killed with signal 11
4 Runtime error 2 ms 576 KB Execution killed with signal 11
5 Runtime error 2 ms 596 KB Execution killed with signal 11
6 Runtime error 2 ms 596 KB Execution killed with signal 11
7 Runtime error 3 ms 596 KB Execution killed with signal 11
8 Runtime error 3 ms 596 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Runtime error 2 ms 596 KB Execution killed with signal 11
3 Runtime error 2 ms 596 KB Execution killed with signal 11
4 Runtime error 2 ms 596 KB Execution killed with signal 11
5 Runtime error 2 ms 596 KB Execution killed with signal 11
6 Runtime error 2 ms 596 KB Execution killed with signal 11
7 Runtime error 2 ms 596 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Runtime error 2 ms 596 KB Execution killed with signal 11
3 Runtime error 2 ms 596 KB Execution killed with signal 11
4 Runtime error 2 ms 596 KB Execution killed with signal 11
5 Runtime error 4 ms 596 KB Execution killed with signal 11
6 Runtime error 3 ms 596 KB Execution killed with signal 11
7 Runtime error 2 ms 520 KB Execution killed with signal 11
8 Runtime error 3 ms 596 KB Execution killed with signal 11
9 Runtime error 2 ms 596 KB Execution killed with signal 11
10 Runtime error 2 ms 596 KB Execution killed with signal 11
11 Runtime error 4 ms 596 KB Execution killed with signal 11
12 Runtime error 3 ms 516 KB Execution killed with signal 11
13 Runtime error 3 ms 596 KB Execution killed with signal 11