답안 #13966

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13966 2015-04-24T16:38:13 Z gs14004 이상한 수열 (OJUZ10_bizarre) C++14
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <set>
using namespace std;

int n,a[100005];
set<int> s;

int main(){
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        scanf("%d",&a[i]);
    }
    int m;
    scanf("%d",&m);
    if(m <= n){
        printf("%d",a[m-1]);
        return 0;
    }
    sort(a,a+n);
    m -= n;
    n = (int)(unique(a,a+n) - a);
    int k = (int)(lower_bound(a,a+n,m) - a);
    if(k == n){
        printf("%d",m - n + 1);
        return 0;
    }
    m--;
    while (m && n < a[k]) {
        n++;
        m--;
    }
    printf("%d",n);
}

Compilation message

bizarre.cpp: In function ‘int main()’:
bizarre.cpp:19:15: error: ‘sort’ was not declared in this scope
     sort(a,a+n);
               ^
bizarre.cpp:21:27: error: ‘unique’ was not declared in this scope
     n = (int)(unique(a,a+n) - a);
                           ^
bizarre.cpp:9:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
bizarre.cpp:11:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
                          ^
bizarre.cpp:14:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&m);
                   ^