# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
975939 |
2024-05-06T03:43:42 Z |
Darren0724 |
Cake (CEOI14_cake) |
C++17 |
|
2000 ms |
13916 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=0;
auto upd=[&](int p)->void {
v[p]=idx++;
t.push_back(p);
};
auto upd1=[&](int p,int x) {
int last=t.size();
upd(p);
for(int j=last-1;j>last-x;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;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;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 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
69 ms |
11760 KB |
Output isn't correct |
2 |
Incorrect |
54 ms |
7672 KB |
Output isn't correct |
3 |
Incorrect |
70 ms |
13708 KB |
Output isn't correct |
4 |
Correct |
54 ms |
5564 KB |
Output is correct |
5 |
Incorrect |
67 ms |
11824 KB |
Output isn't correct |
6 |
Incorrect |
62 ms |
12472 KB |
Output isn't correct |
7 |
Incorrect |
64 ms |
13268 KB |
Output isn't correct |
8 |
Correct |
60 ms |
9936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2059 ms |
2408 KB |
Time limit exceeded |
2 |
Execution timed out |
2045 ms |
2616 KB |
Time limit exceeded |
3 |
Incorrect |
1274 ms |
2740 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Execution timed out |
2097 ms |
4820 KB |
Time limit exceeded |
6 |
Execution timed out |
2007 ms |
4568 KB |
Time limit exceeded |
7 |
Execution timed out |
2068 ms |
4808 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
1736 KB |
Output isn't correct |
2 |
Incorrect |
53 ms |
1084 KB |
Output isn't correct |
3 |
Incorrect |
674 ms |
2512 KB |
Output isn't correct |
4 |
Incorrect |
663 ms |
2508 KB |
Output isn't correct |
5 |
Incorrect |
89 ms |
2760 KB |
Output isn't correct |
6 |
Incorrect |
1767 ms |
3568 KB |
Output isn't correct |
7 |
Incorrect |
394 ms |
2804 KB |
Output isn't correct |
8 |
Incorrect |
106 ms |
8008 KB |
Output isn't correct |
9 |
Execution timed out |
2039 ms |
5576 KB |
Time limit exceeded |
10 |
Incorrect |
253 ms |
9792 KB |
Output isn't correct |
11 |
Incorrect |
1849 ms |
13916 KB |
Output isn't correct |
12 |
Execution timed out |
2064 ms |
5284 KB |
Time limit exceeded |
13 |
Execution timed out |
2035 ms |
5580 KB |
Time limit exceeded |