提交时间:2023-09-18 13:29:45
运行 ID: 103245
#include<bits/stdc++.h> using namespace std; int a[1005]; int main(){ int b,c,Bi=0; bool t=0; cin>>b; for(int i=1;i<=b;i++){ cin>>c; a[c]++; } for(int i=1;i<=b-1;i++){ Bi=0; for(int p=1;p<=1000;p++){ if(a[Bi]<a[p]){ Bi=p; } } if(Bi!=0){ if(t==1){ cout<<"->"<<Bi; }else{ cout<<Bi; t=1; } } a[Bi]=0; } }