# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
976305 |
2024-05-06T12:12:02 Z |
Darren0724 |
Cake (CEOI14_cake) |
C++17 |
|
2000 ms |
11152 KB |
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
//#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e9;
const int K=10;
int32_t main() {
LCBorz;
int n,k;cin>>n>>k;k--;
vector<int> v(n);
vector<int> ans(n);
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>v[i];
a[v[i]-1]=i;
}
vector<int> t;
int idx=1;
auto upd=[&](int p)->void {
//cout<<"upd "<<p<<endl;
v[p]=idx++;
t.push_back(p);
};
auto upd1=[&](int p,int x) {
int last=t.size();
upd(p);
for(int j=last-x+1;j<=last-1;j++){
upd(t[j]);
}
};
for(int i=0;i<n;i++){
upd(a[i]);
}
int q;cin>>q;
for(int i=0;i<q;i++){
char c;cin>>c;
if(c=='F'){
int p;cin>>p;p--;
if(p==k){
cout<<0<<endl;
continue;
}
if(p>k){
int mx=0;
for(int j=k+1;j<=p;j++){
mx=max(mx,v[j]);
}
int cnt=p-k;
for(int j=k-1;j>=0;j--){
if(v[j]>mx)break;
cnt++;
}
cout<<cnt<<endl;
}
else{
int mx=0;
for(int j=k-1;j>=p;j--){
mx=max(mx,v[j]);
}
int cnt=k-p;
for(int j=k+1;j<n;j++){
if(v[j]>mx)break;
cnt++;
}
cout<<cnt<<endl;
}
}
else{
int p,x;cin>>p>>x;p--;
upd1(p,x);
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
79 ms |
9020 KB |
Output isn't correct |
2 |
Correct |
60 ms |
5208 KB |
Output is correct |
3 |
Correct |
83 ms |
9236 KB |
Output is correct |
4 |
Correct |
59 ms |
2764 KB |
Output is correct |
5 |
Incorrect |
80 ms |
9380 KB |
Output isn't correct |
6 |
Incorrect |
68 ms |
9020 KB |
Output isn't correct |
7 |
Correct |
97 ms |
9652 KB |
Output is correct |
8 |
Correct |
60 ms |
5572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2054 ms |
2592 KB |
Time limit exceeded |
2 |
Execution timed out |
2043 ms |
2936 KB |
Time limit exceeded |
3 |
Incorrect |
1637 ms |
2480 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Execution timed out |
2087 ms |
4676 KB |
Time limit exceeded |
6 |
Execution timed out |
2048 ms |
4576 KB |
Time limit exceeded |
7 |
Execution timed out |
2015 ms |
5080 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
1740 KB |
Output isn't correct |
2 |
Correct |
51 ms |
1088 KB |
Output is correct |
3 |
Correct |
673 ms |
2644 KB |
Output is correct |
4 |
Incorrect |
666 ms |
2764 KB |
Output isn't correct |
5 |
Incorrect |
74 ms |
2768 KB |
Output isn't correct |
6 |
Correct |
1953 ms |
2808 KB |
Output is correct |
7 |
Correct |
436 ms |
2244 KB |
Output is correct |
8 |
Correct |
84 ms |
6092 KB |
Output is correct |
9 |
Execution timed out |
2033 ms |
5536 KB |
Time limit exceeded |
10 |
Incorrect |
260 ms |
9640 KB |
Output isn't correct |
11 |
Incorrect |
1981 ms |
11152 KB |
Output isn't correct |
12 |
Execution timed out |
2049 ms |
4816 KB |
Time limit exceeded |
13 |
Execution timed out |
2023 ms |
5580 KB |
Time limit exceeded |