結果

問題 No.241 出席番号(1)
ユーザー syoken_desukasyoken_desuka
提出日時 2015-07-11 00:37:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,975 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 87,804 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 10:33:09
合計ジャッジ時間 2,620 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:74:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
 #endif _DEBUG
        ^~~~~~
main.cpp:83:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
 #endif _DEBUG
        ^~~~~~

ソースコード

diff #

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