Submission #14306

#TimeUsernameProblemLanguageResultExecution timeMemory
14306gs14004이상한 수열 (OJUZ10_bizarre)C++14
100 / 100
15 ms1472 KiB
#include <cstdio> #include <algorithm> using namespace std; int n,a[100005]; int main(){ scanf("%d",&n); for (int i=0; i<n; i++) { scanf("%d",&a[i]); } int m; scanf("%d",&m); if(m <= n){ printf("%d",a[m-1]); return 0; } m -= n; sort(a,a+n); a[n] = 2e9; n++; n = (int)(unique(a,a+n) - a); int k = (int)(lower_bound(a,a+n,n-1) - a); m--; n--; int dist = min(m,a[k] - n); printf("%d",n + dist); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...