3 solutions
-
1
#include<bits/stdc++.h> using namespace std; const int N=25,M=1010; int a[N]; int cnt[M]; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { int x; cin>>x; cnt[x]++; } int i=1; for(int j=0;j<M;j++) { while(cnt[j]>0) { a[i++]=j; cnt[j]--; } } for(int i=1;i<=n;i++) { cout<<a[i]<<" "; } return 0; }
-
1
#include<bits/stdc++.h> using namespace std; const int N=25,M=1010; int a[N]; int cnt[M]; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { int x; cin>>x; cnt[x]++; } int i=1; for(int j=0;j<M;j++) { while(cnt[j]>0) { a[i++]=j; cnt[j]--; } } for(int i=1;i<=n;i++) { cout<<a[i]<<" "; } return 0; }
- 1
Information
- ID
- 115
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 1
- Tags
- (None)
- # Submissions
- 53
- Accepted
- 21
- Uploaded By