結果
| 問題 |
No.241 出席番号(1)
|
| コンテスト | |
| ユーザー |
syoken_desuka
|
| 提出日時 | 2015-07-11 00:37:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,975 bytes |
| コンパイル時間 | 772 ms |
| コンパイル使用メモリ | 90,100 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-08 02:28:25 |
| 合計ジャッジ時間 | 2,184 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 1 |
コンパイルメッセージ
main.cpp:74:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
74 | #endif _DEBUG
| ^~~~~~
main.cpp:83:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
83 | #endif _DEBUG
| ^~~~~~
ソースコード
#include <algorithm>
#include <array>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <ostream>
#include<complex>
#include <cmath>
#include <iostream>
#include <stack>
#include <fstream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <string>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define ALLOF(c) (c),begin(), (c),end()
typedef long long ll;
int main()
{
int n;
int a[50];
int allow_count[50];
int dispatched[50];
bool end[50];
cin >> n;
fill(dispatched,dispatched + 50, -1);
fill(allow_count,allow_count+50, n);
fill(end,end+50,false);
rep(i,n)
{
cin >> a[i];
}
rep(i,n)
{
allow_count[a[i]]--;
}
rep(i,n)
{
if(allow_count[i] == 0)
{
cout << -1 << endl;
return 0;
}
}
rep(i,n)
{
int need_dispatch = 0;
int tmp_c = n+1;
rep(j,n)
{
if ( !end[j] && tmp_c > allow_count[j])
{
need_dispatch = j;
tmp_c = allow_count[j];
}
}
#ifdef _DEBUG
cout << tmp_c << " " << need_dispatch << endl;
#endif _DEBUG
rep(j,n)
{
if (dispatched[j] == -1 && a[j] != need_dispatch)
{
#ifdef _DEBUG
cout << "dispatched in" << j << endl;
#endif _DEBUG
dispatched[j] = need_dispatch;
allow_count[j]++;//あとで全部引くのでプラマイ0補正
end[need_dispatch] = true;
break;
}
}
rep(j,n)
{
allow_count[j]--;
}
}
rep(i,n)
{
cout << dispatched[i] << endl;
}
return 0;
}
syoken_desuka