Submission #13946

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