답안 #14815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14815 2015-06-28T07:08:41 Z eaststar 중앙값 배열 (balkan11_medians) C++
100 / 100
33 ms 1896 KB
#include <stdio.h>
int a[200010],f,r;
int main(){
    int i,n,m,k;
    scanf("%d",&n);
    scanf("%d",&m);
    printf("%d",m);
    a[m]=1;
    r=n*2;
    for(i=1;i<n;++i){
        scanf("%d",&k);
        if(k<m){
            if(a[k]){
                while(a[++f]);
                printf(" %d",f);
            }
            else printf(" %d",k);
            a[k]=1;
            while(a[++f]);
            printf(" %d",f);
            a[f]=1;
        }
        else if(k==m){
            while(a[++f]);
            while(a[--r]);
            printf(" %d %d",f,r);
            a[k]=a[f]=a[r]=1;
        }
        else{
            if(a[k]){
                while(a[--r]);
                printf(" %d",r);
            }
            else printf(" %d",k);
            a[k]=1;
            while(a[--r]);
            printf(" %d",r);
            a[r]=1;
        }
        m=k;
    }
    return 0;
}

Compilation message

medians.cpp: In function 'int main()':
medians.cpp:5:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
medians.cpp:6:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&m);
                   ^
medians.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1896 KB Output is correct
2 Correct 0 ms 1896 KB Output is correct
3 Correct 0 ms 1896 KB Output is correct
4 Correct 0 ms 1896 KB Output is correct
5 Correct 0 ms 1896 KB Output is correct
6 Correct 0 ms 1896 KB Output is correct
7 Correct 0 ms 1896 KB Output is correct
8 Correct 0 ms 1896 KB Output is correct
9 Correct 0 ms 1896 KB Output is correct
10 Correct 0 ms 1896 KB Output is correct
11 Correct 0 ms 1896 KB Output is correct
12 Correct 0 ms 1896 KB Output is correct
13 Correct 0 ms 1896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1896 KB Output is correct
2 Correct 0 ms 1896 KB Output is correct
3 Correct 0 ms 1896 KB Output is correct
4 Correct 3 ms 1896 KB Output is correct
5 Correct 6 ms 1896 KB Output is correct
6 Correct 23 ms 1896 KB Output is correct
7 Correct 33 ms 1896 KB Output is correct