답안 #975943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975943 2024-05-06T03:48:27 Z Darren0724 케이크 (CEOI14_cake) C++17
0 / 100
2000 ms 24756 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 {
        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-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+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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 189 ms 23796 KB Output isn't correct
2 Incorrect 124 ms 13716 KB Output isn't correct
3 Incorrect 151 ms 18868 KB Output isn't correct
4 Incorrect 97 ms 7200 KB Output isn't correct
5 Incorrect 195 ms 24756 KB Output isn't correct
6 Incorrect 180 ms 22504 KB Output isn't correct
7 Incorrect 151 ms 20852 KB Output isn't correct
8 Incorrect 104 ms 11148 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2049 ms 3508 KB Time limit exceeded
2 Incorrect 1850 ms 3472 KB Output isn't correct
3 Incorrect 1191 ms 3720 KB Output isn't correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Execution timed out 2080 ms 7572 KB Time limit exceeded
6 Execution timed out 2029 ms 7556 KB Time limit exceeded
7 Incorrect 1767 ms 7824 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 2760 KB Output isn't correct
2 Incorrect 51 ms 1944 KB Output isn't correct
3 Incorrect 605 ms 3804 KB Output isn't correct
4 Incorrect 615 ms 4816 KB Output isn't correct
5 Incorrect 99 ms 5824 KB Output isn't correct
6 Incorrect 1586 ms 5528 KB Output isn't correct
7 Incorrect 357 ms 4532 KB Output isn't correct
8 Incorrect 130 ms 11672 KB Output isn't correct
9 Execution timed out 2025 ms 9412 KB Time limit exceeded
10 Incorrect 330 ms 19540 KB Output isn't correct
11 Incorrect 1782 ms 23608 KB Output isn't correct
12 Execution timed out 2078 ms 8704 KB Time limit exceeded
13 Execution timed out 2063 ms 8892 KB Time limit exceeded