Submission #14120

#TimeUsernameProblemLanguageResultExecution timeMemory
14120juchan1220이상한 수열 (OJUZ10_bizarre)C++98
100 / 100
15 ms1472 KiB
#include <stdio.h> #include <algorithm> using namespace std; int s[50001],b[50001]; int main (void) { int i,n,m,cnt=1,cnt2,mn=0; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&s[i]); b[i]=s[i]; } sort(b,b+n); for(i=1;i<n;i++){ if(b[i-1]!=b[i]) cnt++; } scanf("%d",&m); if(m<=n){ printf("%d\n",s[m-1]); return 0; } cnt2=(m-n-1)+cnt; for(i=0;i<n;i++){ if(cnt<=b[i] && b[i]<=cnt2){ if(mn==0) mn=b[i]; else if(mn>b[i]) mn=b[i]; } } if(mn==0) printf("%d\n",cnt2); else printf("%d\n",mn); 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...