結果

問題 No.241 出席番号(1)
ユーザー itezpaceitezpace
提出日時 2016-11-01 09:05:17
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 951 bytes
コンパイル時間 618 ms
コンパイル使用メモリ 70,884 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 19:23:59
合計ジャッジ時間 3,668 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 RE -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
}
0