Submission #198250

# Submission time Handle Problem Language Result Execution time Memory
198250 2020-01-25T08:53:08 Z mehrdad_sohrabi Cake (CEOI14_cake) C++14
0 / 100
2000 ms 5480 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=3e5+100;
ll val[N];
ll b[N];
ll a,n;
void solve(){
    b[a]=0;
    val[0]=1e9;
    val[n+1]=1e9;
    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;
            if (cnt>=val[id]){
                for (int j=1;j<=n;j++){
                    if (val[j]<=cnt && val[j]>=val[id]) val[j]--;
                }
            }
            else{
                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 2043 ms 1356 KB Time limit exceeded
2 Execution timed out 2024 ms 1484 KB Time limit exceeded
3 Execution timed out 2007 ms 1356 KB Time limit exceeded
4 Execution timed out 2033 ms 1468 KB Time limit exceeded
5 Execution timed out 2055 ms 1076 KB Time limit exceeded
6 Execution timed out 2039 ms 1216 KB Time limit exceeded
7 Execution timed out 2071 ms 1100 KB Time limit exceeded
8 Execution timed out 2009 ms 1224 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 86 ms 3136 KB Output is correct
2 Correct 53 ms 2936 KB Output is correct
3 Correct 50 ms 3064 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Correct 145 ms 5480 KB Output is correct
6 Incorrect 133 ms 5412 KB Output isn't correct
7 Correct 91 ms 5228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 406 ms 996 KB Output isn't correct
2 Incorrect 653 ms 1080 KB Output isn't correct
3 Execution timed out 2051 ms 1580 KB Time limit exceeded
4 Execution timed out 2040 ms 1688 KB Time limit exceeded
5 Incorrect 808 ms 2092 KB Output isn't correct
6 Execution timed out 2020 ms 1676 KB Time limit exceeded
7 Execution timed out 2054 ms 1684 KB Time limit exceeded
8 Execution timed out 2067 ms 2040 KB Time limit exceeded
9 Execution timed out 2045 ms 4136 KB Time limit exceeded
10 Execution timed out 2032 ms 4212 KB Time limit exceeded
11 Execution timed out 2078 ms 1492 KB Time limit exceeded
12 Execution timed out 2025 ms 3516 KB Time limit exceeded
13 Execution timed out 2028 ms 4272 KB Time limit exceeded