답안 #14058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14058 2015-04-26T02:01:50 Z kipa00 이상한 수열 (OJUZ10_bizarre) C++
100 / 100
14 ms 1600 KB
#include <cstdio>
#include <algorithm>
using namespace std;

int arr[50000];
int main() {
    int N, i, differ = 1, sup = 1000001, ord, tst;
    scanf("%d", &N);
    for (i=0; i<N; ++i) {
        scanf("%d", arr+i);
    }
    scanf("%d", &ord);
    if (ord <= N) {
        printf("%d\n", arr[ord - 1]);
        return 0;
    }
    stable_sort(arr, arr+N);
    for (i=1; i<N; ++i) {
        differ += (arr[i] != arr[i - 1]);
    }
    for (i=0; i<N; ++i) {
        if (arr[i] >= differ) {
            sup = arr[i];
            break;
        }
    }
    tst = ord - (N + 1) + differ;
    if (i < N && tst >= sup) tst = sup;
    printf("%d\n", tst);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1408 KB Output is correct
2 Correct 0 ms 1408 KB Output is correct
3 Correct 0 ms 1408 KB Output is correct
4 Correct 0 ms 1408 KB Output is correct
5 Correct 0 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1408 KB Output is correct
2 Correct 0 ms 1408 KB Output is correct
3 Correct 0 ms 1408 KB Output is correct
4 Correct 0 ms 1408 KB Output is correct
5 Correct 0 ms 1408 KB Output is correct
6 Correct 0 ms 1408 KB Output is correct
7 Correct 0 ms 1408 KB Output is correct
8 Correct 0 ms 1408 KB Output is correct
9 Correct 0 ms 1408 KB Output is correct
10 Correct 0 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 0 ms 1408 KB Output is correct
3 Correct 0 ms 1564 KB Output is correct
4 Correct 3 ms 1408 KB Output is correct
5 Correct 0 ms 1408 KB Output is correct
6 Correct 0 ms 1408 KB Output is correct
7 Correct 5 ms 1408 KB Output is correct
8 Correct 1 ms 1408 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 14 ms 1600 KB Output is correct
12 Correct 6 ms 1408 KB Output is correct
13 Correct 6 ms 1556 KB Output is correct
14 Correct 12 ms 1600 KB Output is correct
15 Correct 10 ms 1600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1600 KB Output is correct
2 Correct 6 ms 1564 KB Output is correct
3 Correct 8 ms 1600 KB Output is correct
4 Correct 5 ms 1600 KB Output is correct
5 Correct 0 ms 1408 KB Output is correct
6 Correct 12 ms 1600 KB Output is correct
7 Correct 8 ms 1600 KB Output is correct
8 Correct 14 ms 1600 KB Output is correct
9 Correct 6 ms 1408 KB Output is correct
10 Correct 0 ms 1408 KB Output is correct
11 Correct 2 ms 1408 KB Output is correct
12 Correct 13 ms 1600 KB Output is correct
13 Correct 6 ms 1592 KB Output is correct
14 Correct 3 ms 1408 KB Output is correct
15 Correct 8 ms 1556 KB Output is correct