답안 #101541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101541 2019-03-19T03:52:06 Z jamielim 케이크 (CEOI14_cake) C++14
15 / 100
2000 ms 1672 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,a;
    scanf("%d%d",&n,&a); a--;
    int arr[n];
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    int q;
    scanf("%d",&q);
    char op[5]; int x,y;
    for(int i=0;i<q;i++){
        scanf("%s%d",op,&x); x--;
        if(op[0]=='E'){
            scanf("%d",&y); y--;
            for(int j=0;j<n;j++){
                if(arr[j]>arr[x]&&arr[j]<=n-y){
                    arr[j]--;
                }
            }
            arr[x]=n-y;
        }else{
            if(a==x){
                printf("0\n");
                continue;
            }
            int l=a-1,r=a+1;
            int ans=1;
            while(l!=x&&r!=x){
                if(l==-1){r++; ans++;}
                else if(r==n){l--; ans++;}
                else if(arr[l]>arr[r]){
                    r++; ans++;
                }else if(arr[l]<arr[r]){
                    l--; ans++;
                }
            }
            if(l==x){
                while(r<n&&arr[l]>arr[r]){r++; ans++;}
            }else{
                while(l>=0&&arr[l]<arr[r]){l--;ans++;}
            }
            printf("%d\n",ans);
        }
    }
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&a); a--;
     ~~~~~^~~~~~~~~~~~~~
cake.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~
cake.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&q);
     ~~~~~^~~~~~~~~
cake.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s%d",op,&x); x--;
         ~~~~~^~~~~~~~~~~~~~
cake.cpp:17:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&y); y--;
             ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 13 ms 256 KB Output is correct
5 Correct 213 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2100 ms 384 KB Time limit exceeded
2 Execution timed out 2057 ms 384 KB Time limit exceeded
3 Execution timed out 2060 ms 384 KB Time limit exceeded
4 Execution timed out 2062 ms 384 KB Time limit exceeded
5 Execution timed out 2033 ms 452 KB Time limit exceeded
6 Execution timed out 2041 ms 384 KB Time limit exceeded
7 Execution timed out 2017 ms 384 KB Time limit exceeded
8 Execution timed out 2051 ms 384 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2040 ms 988 KB Time limit exceeded
2 Execution timed out 2066 ms 1020 KB Time limit exceeded
3 Execution timed out 2089 ms 1188 KB Time limit exceeded
4 Correct 2 ms 256 KB Output is correct
5 Execution timed out 2055 ms 1524 KB Time limit exceeded
6 Execution timed out 2020 ms 1496 KB Time limit exceeded
7 Execution timed out 2045 ms 1672 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 373 ms 572 KB Output is correct
2 Correct 550 ms 508 KB Output is correct
3 Execution timed out 2094 ms 708 KB Time limit exceeded
4 Execution timed out 2025 ms 860 KB Time limit exceeded
5 Correct 700 ms 692 KB Output is correct
6 Execution timed out 2029 ms 744 KB Time limit exceeded
7 Execution timed out 2051 ms 728 KB Time limit exceeded
8 Execution timed out 2009 ms 640 KB Time limit exceeded
9 Execution timed out 2057 ms 1528 KB Time limit exceeded
10 Execution timed out 2053 ms 1532 KB Time limit exceeded
11 Execution timed out 2037 ms 648 KB Time limit exceeded
12 Execution timed out 2047 ms 1272 KB Time limit exceeded
13 Execution timed out 2055 ms 1600 KB Time limit exceeded