Submission #14033

#TimeUsernameProblemLanguageResultExecution timeMemory
14033baneling100이상한 수열 (OJUZ10_bizarre)C++98
100 / 100
14 ms1276 KiB
#include <stdio.h> #include <algorithm> #define INF 0x7fffffff using namespace std; int N, S[50001], M, K, Ans; int main(void) { int i; scanf("%d",&N); for(i=1 ; i<=N ; i++) scanf("%d",&S[i]); scanf("%d",&M); if(M<=N) printf("%d",S[M]); else { sort(S+1,S+N+1); S[0]=-INF; for(i=1 ; i<=N ; i++) if(S[i]!=S[i-1]) K++; Ans=K+M-N-1; for(i=1 ; i<=N ; i++) if(K<=S[i] && S[i]<=K+M-N-1 && Ans>S[i]) Ans=S[i]; printf("%d",Ans); } 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...