Submission #14293

#TimeUsernameProblemLanguageResultExecution timeMemory
14293mindol이상한 수열 (OJUZ10_bizarre)C++98
100 / 100
29 ms23184 KiB
#include<cstdio> #include<algorithm> #include<set> int s[50001]; int b[5000000]; std::set<int> st; int main() { int n,m,i,mx=-987654321; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&s[i]),b[i]=s[i],st.insert(s[i]),mx=std::max(mx,s[i]); std::set<int>::iterator k=st.upper_bound(st.size()-1); scanf("%d",&m); /*for(i=1;i<=m;i++) { if(*k>mx) { if(i<=n) printf("%d",b[i]); else printf("%d",st.size()+i-n-1); } else { if(i<=n) printf("%d",b[i]); else if(i<=n+(*k-st.size()+1)) printf("%d",i-n-1+st.size()); else printf("%d",*k); } printf(" "); } printf("\n------------------------------\n"); for(i=1;i<=m;i++) { if(i<=n) printf("%d",b[i]); else printf("%d",b[i]=st.size()),st.insert(b[i]); printf(" "); }*/ if(*k>mx) { if(m<=n) printf("%d",b[m]); else printf("%d",st.size()+m-n-1); } else { if(m<=n) printf("%d",b[m]); else if(m<=n+(*k-st.size()+1)) printf("%d",m-n-1+st.size()); else printf("%d",*k); } 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...