Submission #470251

# Submission time Handle Problem Language Result Execution time Memory
470251 2021-09-03T10:30:52 Z MohamedFaresNebili Cake (CEOI14_cake) C++14
35 / 100
2000 ms 2844 KB
#include <bits/stdc++.h>
 
using namespace std;
 
using ll  = long long;
using ld  = long double;
using vl  = vector<long long>;
 
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin() , (x).end()
 
const ll MOD = 998244353;
const long double EPS = 0.000000001;
const double PI = 3.14159265358979323846;
 
int32_t main()
{
    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int n, m, q; cin>>n>>m; int arr[n+2]; arr[0]=INT_MAX, arr[n+1]=INT_MAX;
    for(int l=1;l<=n;l++) cin>>arr[l];
    cin>>q; int l=m-1, r=m+1, next=m; int ans[n+2]{0}, res=0;
    while(l>=1||r<=n) {
        if(arr[l]<arr[r]) next=l--;
        else next=r++;
        ans[next]=++res;
    }
    while(q--) {
        char ch; cin>>ch;
        if(ch=='F') {
            int a; cin>>a;
            cout<<ans[a]<<'\n';
        }
        else if(ch=='E') {
            int a, b; cin>>a>>b;
            for(int l=1;l<=n;l++) {
                if(l==a) continue;
                if(n-arr[l]+1>=b&&n-arr[l]+1<n-arr[a]+1) arr[l]--;
            }
            arr[a]=n-b+1;
            l=m-1, r=m+1, next=m, res=0;
            while(l>=1||r<=n) {
                if(arr[l]<arr[r]) next=l--;
                else next=r++;
                ans[next]=++res;
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 18 ms 332 KB Output is correct
5 Correct 268 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2052 ms 332 KB Time limit exceeded
2 Execution timed out 2063 ms 332 KB Time limit exceeded
3 Execution timed out 2082 ms 332 KB Time limit exceeded
4 Execution timed out 2078 ms 364 KB Time limit exceeded
5 Execution timed out 2086 ms 460 KB Time limit exceeded
6 Execution timed out 2073 ms 460 KB Time limit exceeded
7 Execution timed out 2075 ms 460 KB Time limit exceeded
8 Execution timed out 2075 ms 460 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 105 ms 1656 KB Output is correct
2 Correct 55 ms 1480 KB Output is correct
3 Correct 54 ms 1460 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 145 ms 2796 KB Output is correct
6 Correct 144 ms 2844 KB Output is correct
7 Correct 106 ms 2628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 418 ms 332 KB Output is correct
2 Correct 666 ms 348 KB Output is correct
3 Execution timed out 2083 ms 820 KB Time limit exceeded
4 Execution timed out 2078 ms 864 KB Time limit exceeded
5 Correct 805 ms 688 KB Output is correct
6 Execution timed out 2082 ms 952 KB Time limit exceeded
7 Execution timed out 2082 ms 596 KB Time limit exceeded
8 Execution timed out 2097 ms 1084 KB Time limit exceeded
9 Execution timed out 2086 ms 2256 KB Time limit exceeded
10 Execution timed out 2082 ms 1152 KB Time limit exceeded
11 Execution timed out 2084 ms 612 KB Time limit exceeded
12 Execution timed out 2094 ms 1856 KB Time limit exceeded
13 Execution timed out 2090 ms 2372 KB Time limit exceeded