Submission #14437

#TimeUsernameProblemLanguageResultExecution timeMemory
14437ansol4328이상한 수열 (OJUZ10_bizarre)C++98
100 / 100
13 ms8972 KiB
#include<stdio.h> #define X 1000000 int check[2000005]; int main() { int n, m[50005], k, i, cnt=0, a; scanf("%d",&n); for(i=1 ; i<=n ; i++) { scanf("%d",&m[i]); if(check[m[i]+X]==0) cnt++, check[m[i]+X]=1; } scanf("%d",&k); if(n>=k) printf("%d",m[k]); else { a=n; while(a<=k-2) { if(check[cnt+X]==0) { check[cnt+X]=1; cnt++; if(cnt==X+1) { cnt+=(k-2-a); break; } } else break; a++; } printf("%d",cnt); } 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...