#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);
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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
371 ms |
5208 KB |
Output isn't correct |
2 |
Incorrect |
241 ms |
5156 KB |
Output isn't correct |
3 |
Incorrect |
286 ms |
5148 KB |
Output isn't correct |
4 |
Incorrect |
180 ms |
5272 KB |
Output isn't correct |
5 |
Incorrect |
420 ms |
6160 KB |
Output isn't correct |
6 |
Incorrect |
356 ms |
6564 KB |
Output isn't correct |
7 |
Incorrect |
313 ms |
6428 KB |
Output isn't correct |
8 |
Incorrect |
286 ms |
6672 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2086 ms |
6620 KB |
Time limit exceeded |
2 |
Execution timed out |
2087 ms |
6928 KB |
Time limit exceeded |
3 |
Execution timed out |
2087 ms |
6816 KB |
Time limit exceeded |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Execution timed out |
2075 ms |
15132 KB |
Time limit exceeded |
6 |
Execution timed out |
2070 ms |
15136 KB |
Time limit exceeded |
7 |
Execution timed out |
2093 ms |
15132 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
89 ms |
932 KB |
Output isn't correct |
2 |
Incorrect |
111 ms |
988 KB |
Output isn't correct |
3 |
Incorrect |
1374 ms |
3944 KB |
Output isn't correct |
4 |
Correct |
1513 ms |
4060 KB |
Output is correct |
5 |
Incorrect |
212 ms |
1740 KB |
Output isn't correct |
6 |
Execution timed out |
2073 ms |
5284 KB |
Time limit exceeded |
7 |
Incorrect |
792 ms |
2896 KB |
Output isn't correct |
8 |
Incorrect |
345 ms |
7840 KB |
Output isn't correct |
9 |
Execution timed out |
2087 ms |
15136 KB |
Time limit exceeded |
10 |
Incorrect |
713 ms |
5116 KB |
Output isn't correct |
11 |
Execution timed out |
2090 ms |
4768 KB |
Time limit exceeded |
12 |
Execution timed out |
2070 ms |
12352 KB |
Time limit exceeded |
13 |
Execution timed out |
2066 ms |
15328 KB |
Time limit exceeded |