이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<algorithm>
using namespace std;
int w[101000], n, m, c;
int main(){
int i, t;
scanf("%d", &n);
for (i = 1; i <= n; i++){
scanf("%d", &w[i]);
}
scanf("%d", &m);
if (m <= n){
printf("%d\n", w[m]);
return 0;
}
sort(w + 1, w + n + 1);
for (i = 1; i <= n; i++){
if (i == 1 || w[i] != w[i - 1])c++;
}
for (i = 1; i <= n; i++)if (w[i] >= c)break;
t = i;
if (t == n + 1 || w[t] - c > m - (n+1)){
printf("%d\n", m - (n + 1) + c);
}
else printf("%d\n", w[t]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |