Submission #14149

#TimeUsernameProblemLanguageResultExecution timeMemory
14149ggoh버블 정렬 (OJUZ10_bubblesort)C++98
34 / 100
242 ms11836 KiB
#include<cstdio> #include<algorithm> #include<map> int a,b,i,j,t,p,q,m,n,s,x[160001],y[160001]; std::map<int,int>D,U; main() { scanf("%d%d",&a,&b); for(i=0;i<a;i++) { scanf("%d",&x[i]); y[i]=x[i]; U[x[i]]++; } if(a<=2000) { while(b--) { for(i=0;i<a-1;i++) { if(x[i]>x[i+1]) { t=x[i]; x[i]=x[i+1]; x[i+1]=t; } } } for(i=0;i<a;i++) { printf("%d ",x[i]); } return 0; } std::sort(y,y+a); for(i=a-b;i<a;i++) { D[y[i]]++; } for(i=0;i<a;i++) { if(D[x[i]]!=U[x[i]]) { printf("%d ",x[i]); D[x[i]]++; } } for(i=a-b;i<a;i++) { printf("%d ",y[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...