Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int arr[10005];
- int main()
- {
- int n,i,j,mn,mx,cnt;
- while(scanf("%d",&n)&&n)
- {
- for(i=1; i<=n; i++)
- {
- scanf("%d",&arr[i]);
- }
- sort(arr+1,arr+n+1);
- mx = mn = 1;
- for(i=2; i<=n; i++)
- {
- mx = max(mx,mn);
- if(arr[i]==arr[i-1])
- {
- mn++;
- mx = max(mx,mn);
- }
- else
- {
- mn = 1;
- }
- }
- printf("%d\n",mx);
- for(i=1; i<=mx; i++)
- {
- cnt = 0;
- for(j=i; j<=n; j+=mx)
- {
- if(cnt>0)
- printf(" %d",arr[j]);
- else
- printf("%d",arr[j]);
- cnt = 1;
- }
- puts("");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment