Submission #14450

#TimeUsernameProblemLanguageResultExecution timeMemory
14450yys980이상한 수열 (OJUZ10_bizarre)C++98
100 / 100
18 ms9324 KiB
#include <stdio.h> #include <algorithm> using namespace std; int n,m; int a[110000],cnt=0,Mnt; int check[2000100]; int main() { scanf("%d",&n); int i,f=0; for(i = 1 ; i <= n ; i++){ scanf("%d",&a[i]); if(check[a[i]+1000000]==0)cnt++; check[a[i]+1000000]=1; } scanf("%d",&m); if(m <= n){ printf("%d",a[m]); } else { Mnt=m-n+cnt-1; sort(a+1,a+n+1); for(i = 1 ; i <= n ; i++){ if(a[i]<cnt)continue; if(a[i]>=Mnt)break; f=1; printf("%d",a[i]); break; } if(f==0)printf("%d",Mnt); } 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...