Submission #676576

# Submission time Handle Problem Language Result Execution time Memory
676576 2022-12-31T10:35:35 Z vjudge1 Cake (CEOI14_cake) C++17
35 / 100
2000 ms 4844 KB
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
 
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#define int long long
#define endl '\n'
#define mod 1000000007;
using namespace std;

int A[250001],ans[250001];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n,a; cin >> n >> a;
    for(int i = 0; i < n; i++) cin >> A[i];
    
    int l = a - 2, r = a, cnt = 0;
    ans[a - 1] = 0;
    while(l >= 0 or r < n){
        int mx1 = 1e18, mx2 = 1e18;
        cnt++;
        if(l >= 0){
            mx1 = A[l];
        }
        if(r < n){
            mx2 = A[r];
        }
        if(mx1 < mx2){
            ans[l] = cnt;
            l--;
        }else{
            ans[r] = cnt;
            r++;
        }
    }
    int t; cin >> t;
    while(t--){
        char x; int c,d; cin >> x >> c;
        if(x == 'E'){
            cin >> d;
            int new_val = n - d + 1;
            if(A[c - 1] > new_val){
                for(int i = 0; i < n; i++){
                    if(A[i] >= new_val && A[i] < A[c - 1]){
                        A[i]++;
                    }
                }
                A[c - 1] = new_val;
                
            }else if(A[c - 1] < new_val){
                for(int i = 0; i < n; i++){
                    if(A[i] > A[c - 1] && A[i] <= new_val){
                        A[i]--;
                    }
                }
                A[c - 1] = new_val;
            }
            int l = a - 2, r = a, cnt = 0;
            ans[a - 1] = 0;
            while(l >= 0 or r < n){
                int mx1 = 1e18, mx2 = 1e18;
                cnt++;
                if(l >= 0){
                    mx1 = A[l];
                }
                if(r < n){
                    mx2 = A[r];
                }
                if(mx1 < mx2){
                    ans[l] = cnt;
                    l--;
                }else{
                    ans[r] = cnt;
                    r++;
                }
            }
            
        }else{
            cout << ans[c - 1] << endl;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 13 ms 340 KB Output is correct
5 Correct 219 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2035 ms 468 KB Time limit exceeded
2 Execution timed out 2078 ms 468 KB Time limit exceeded
3 Execution timed out 2072 ms 468 KB Time limit exceeded
4 Execution timed out 2087 ms 468 KB Time limit exceeded
5 Execution timed out 2073 ms 596 KB Time limit exceeded
6 Execution timed out 2090 ms 724 KB Time limit exceeded
7 Execution timed out 2078 ms 724 KB Time limit exceeded
8 Execution timed out 2098 ms 724 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 63 ms 2388 KB Output is correct
2 Correct 42 ms 2248 KB Output is correct
3 Correct 39 ms 2232 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 108 ms 4844 KB Output is correct
6 Correct 103 ms 4832 KB Output is correct
7 Correct 74 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 354 ms 564 KB Output is correct
2 Correct 544 ms 492 KB Output is correct
3 Execution timed out 2098 ms 1148 KB Time limit exceeded
4 Execution timed out 2097 ms 1392 KB Time limit exceeded
5 Correct 665 ms 680 KB Output is correct
6 Execution timed out 2099 ms 1356 KB Time limit exceeded
7 Execution timed out 2094 ms 888 KB Time limit exceeded
8 Execution timed out 2096 ms 1876 KB Time limit exceeded
9 Execution timed out 2099 ms 4216 KB Time limit exceeded
10 Execution timed out 2086 ms 1288 KB Time limit exceeded
11 Execution timed out 2094 ms 872 KB Time limit exceeded
12 Execution timed out 2098 ms 3532 KB Time limit exceeded
13 Execution timed out 2100 ms 4180 KB Time limit exceeded