Submission #14058

#TimeUsernameProblemLanguageResultExecution timeMemory
14058kipa00이상한 수열 (OJUZ10_bizarre)C++98
100 / 100
14 ms1600 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...