답안 #14358

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14358 2015-05-12T11:41:05 Z Fakeable 이상한 수열 (OJUZ10_bizarre) C++
100 / 100
14 ms 1280 KB
#include<cstdio>
#include<algorithm>
#define MAX_N 50500
using namespace std;
int n,m,a[MAX_N];
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    scanf("%d",&m);
    if(m<=n) {
        printf("%d\n",a[m]);
        return 0;
    }
    sort(a+1,a+n+1);
    int t = n, iter = 1;
    for(int i=1;i<n;i++) if(a[i] == a[i+1]) t--;
    bool isin = false;
    for(int i=1;i<=n;i++) {
        if(t == a[i]) {
            isin = true;
            break;
        }
    }
    if(isin) {
        printf("%d\n",t);
        return 0;
    }
    // 2 13 2 2 처럼 constant 가 되어버리는 경우의 수를 처리
    m -= n+1;
    while(iter <= n && a[iter]<t) iter ++;
    if(iter > n) {
        printf("%d\n",t+m);
        return 0;
    }
    int length = a[iter] - t;
    if(length >= m) printf("%d\n",t+m);
    else printf("%d\n",a[iter]);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1280 KB Output is correct
2 Correct 0 ms 1280 KB Output is correct
3 Correct 0 ms 1280 KB Output is correct
4 Correct 0 ms 1280 KB Output is correct
5 Correct 0 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1280 KB Output is correct
2 Correct 0 ms 1280 KB Output is correct
3 Correct 0 ms 1280 KB Output is correct
4 Correct 0 ms 1280 KB Output is correct
5 Correct 0 ms 1280 KB Output is correct
6 Correct 0 ms 1280 KB Output is correct
7 Correct 0 ms 1280 KB Output is correct
8 Correct 0 ms 1280 KB Output is correct
9 Correct 0 ms 1280 KB Output is correct
10 Correct 0 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1280 KB Output is correct
2 Correct 10 ms 1280 KB Output is correct
3 Correct 0 ms 1280 KB Output is correct
4 Correct 0 ms 1280 KB Output is correct
5 Correct 0 ms 1280 KB Output is correct
6 Correct 7 ms 1280 KB Output is correct
7 Correct 0 ms 1280 KB Output is correct
8 Correct 13 ms 1280 KB Output is correct
9 Correct 13 ms 1280 KB Output is correct
10 Correct 0 ms 1280 KB Output is correct
11 Correct 0 ms 1280 KB Output is correct
12 Correct 8 ms 1280 KB Output is correct
13 Correct 0 ms 1280 KB Output is correct
14 Correct 0 ms 1280 KB Output is correct
15 Correct 5 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1280 KB Output is correct
2 Correct 12 ms 1280 KB Output is correct
3 Correct 0 ms 1280 KB Output is correct
4 Correct 8 ms 1280 KB Output is correct
5 Correct 0 ms 1280 KB Output is correct
6 Correct 0 ms 1280 KB Output is correct
7 Correct 2 ms 1280 KB Output is correct
8 Correct 0 ms 1280 KB Output is correct
9 Correct 10 ms 1280 KB Output is correct
10 Correct 14 ms 1280 KB Output is correct
11 Correct 0 ms 1280 KB Output is correct
12 Correct 8 ms 1280 KB Output is correct
13 Correct 0 ms 1280 KB Output is correct
14 Correct 0 ms 1280 KB Output is correct
15 Correct 0 ms 1280 KB Output is correct