标签:std limit pre desc block tput scan 表示 can
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6716 Accepted Submission(s): 2492
3 12 5 -15 31 2 3 4 50 0
55 4 3
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int a[100005]; 6 int n,m,i,j,k; 7 while(scanf("%d%d",&n,&m)&&m&&n) 8 { 9 k=0; 10 for(i=0;i<n;i++) 11 scanf("%d",&a[i]); 12 sort(a,a+n); 13 if(m>n) 14 { 15 for(i=n-1;i>=0;i--) 16 { 17 printf("%d",a[n]); 18 if(i!=0) 19 printf(" "); 20 } 21 printf("\n"); 22 continue; 23 } 24 for(i=n-1;i>=n-m;i--) 25 { 26 if(a[i]<0) 27 { 28 j=i; 29 k=1; 30 break; 31 } 32 printf("%d",a[i]); 33 if(i!=n-m) 34 printf(" "); 35 } 36 if(k!=0) 37 { 38 for(i=j;i>=0;i++) 39 { 40 printf("%d",a[i]); 41 if(i!=0) 42 printf(" "); 43 } 44 } 45 printf("\n"); 46 } 47 return 0; 48 }
标签:std limit pre desc block tput scan 表示 can
原文地址:https://www.cnblogs.com/fangxiaoqi/p/10343070.html