Submission #198244

# Submission time Handle Problem Language Result Execution time Memory
198244 2020-01-25T08:47:31 Z mehrdad_sohrabi Cake (CEOI14_cake) C++14
0 / 100
2000 ms 2808 KB
#include <bits/stdc++.h>
typedef int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
//#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
using namespace std;
const int N=2e5+100;
ll val[N];
ll b[N];
ll a,n;
void solve(){
    b[a]=0;
    val[0]=1e9+100;
    val[n+1]=1e9+100;
    ll l=a-1,r=a+1;
    for (int i=1;i<n;i++){
        if (val[l]<val[r]){
            b[l]=i;
            l--;
        }
        else{
            b[r]=i;
            r++;
        }
    }
}
int32_t main(){
    sync;
    cin >> n >> a;
    for (int i=1;i<=n;i++){
        cin >> val[i];
    }
    solve();
    ll q;
    cin >> q;
    for (int i=0;i<q;i++){
        char c;
        cin >> c;
        if (c=='E'){
            ll id,cnt;
            cin >> id >> cnt;
            cnt=n-cnt+1;
            for (int j=1;j<=n;j++){
                if (val[j]<=cnt && val[j]>=val[id]) val[j]--;
            }
            val[id]=cnt;
            solve();
        }
        else{
            ll id;
            cin >> id;
            cout << b[id] << endl;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2044 ms 1340 KB Time limit exceeded
2 Execution timed out 2045 ms 1528 KB Time limit exceeded
3 Execution timed out 2033 ms 1400 KB Time limit exceeded
4 Execution timed out 2064 ms 1092 KB Time limit exceeded
5 Execution timed out 2025 ms 1084 KB Time limit exceeded
6 Execution timed out 2031 ms 1244 KB Time limit exceeded
7 Execution timed out 2068 ms 1084 KB Time limit exceeded
8 Execution timed out 2074 ms 1204 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 84 ms 2360 KB Output is correct
2 Correct 51 ms 2168 KB Output is correct
3 Correct 50 ms 2168 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Runtime error 28 ms 2680 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 28 ms 2780 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 26 ms 2808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 403 ms 888 KB Output isn't correct
2 Incorrect 657 ms 1128 KB Output isn't correct
3 Execution timed out 2048 ms 1556 KB Time limit exceeded
4 Execution timed out 2077 ms 1820 KB Time limit exceeded
5 Incorrect 806 ms 1912 KB Output isn't correct
6 Execution timed out 2023 ms 1668 KB Time limit exceeded
7 Execution timed out 2092 ms 1556 KB Time limit exceeded
8 Execution timed out 2025 ms 1784 KB Time limit exceeded
9 Runtime error 28 ms 2680 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Execution timed out 2070 ms 2480 KB Time limit exceeded
11 Execution timed out 2070 ms 1472 KB Time limit exceeded
12 Execution timed out 2076 ms 2652 KB Time limit exceeded
13 Runtime error 28 ms 2552 KB Execution killed with signal 11 (could be triggered by violating memory limits)