結果
問題 | No.241 出席番号(1) |
ユーザー |
|
提出日時 | 2016-11-01 09:05:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 951 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 68,744 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 04:29:11 |
合計ジャッジ時間 | 3,138 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 RE * 3 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>using namespace std;int main(){int N;cin>>N;vector<int> v1(N),v2(N);for(int i=0;i<N;++i){cin>>v1[i];v2[v1[i]]+=1;}vector<pair<int,int>> vp1(N);for(int i=0;i<N;++i){vp1[i]=make_pair(v2[i],i);}sort(vp1.begin(),vp1.end(),greater<pair<int,int>>());vector<int> v3(N);int f=0;for(int i=0;i<N;++i){int fd=0;if(v1[i]==vp1[0].second){fd=1;if(vp1[0].first>=N-i){f=1;break;}}int f2=0;for(int j=0;j<vp1.size();++j){if(v1[i]!=vp1[j].second){v3[i]=vp1[j].second;if(fd==1) vp1[0].first-=1;vp1.erase(vp1.begin()+j);sort(vp1.begin(),vp1.end(),greater<pair<int,int>>());f2=1;break;}}if(f2==0){//}}if(f==0){for(int i=0;i<N;++i){cout<<v3[i]<<endl;}} else {cout<<-1<<endl;}}