답안 #103039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103039 2019-03-28T20:27:58 Z rzbt 중앙값 배열 (balkan11_medians) C++14
100 / 100
35 ms 2424 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 200005
using namespace std;

int n,q;


bool dodat[MAXN];
int prvi=1,poslednji,prosli;

void dp(){
    while(dodat[prvi])prvi++;
    dodat[prvi]=true;
    printf("%d ",prvi);
}
void dk(){
    while(dodat[poslednji])poslednji--;
    dodat[poslednji]=true;
    printf("%d ",poslednji);
}


int main()
{
    int n;
    scanf("%d", &n);
    poslednji=n+n-1;
    scanf("%d",&prosli);
    dodat[prosli]=true;
    printf("%d ",prosli);
    for(int i=2;i<=n;i++){
        int t;

        scanf("%d", &t);
        if(t==prosli){
            dp();
            dk();
        }else if(prosli<t){
            if(dodat[t])dk();
            else{
                dodat[t]=true;
                printf("%d ",t);
            }
            dk();
        }else{
            if(dodat[t])dp();
            else{
                dodat[t]=true;
                printf("%d ",t);
            }
            dp();
        }



        prosli=t;
    }


    return 0;
}

Compilation message

medians.cpp: In function 'int main()':
medians.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
medians.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&prosli);
     ~~~~~^~~~~~~~~~~~~~
medians.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &t);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 488 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 8 ms 512 KB Output is correct
4 Correct 7 ms 640 KB Output is correct
5 Correct 22 ms 1024 KB Output is correct
6 Correct 27 ms 1664 KB Output is correct
7 Correct 35 ms 2424 KB Output is correct