結果

問題 No.190 Dry Wet Moist
ユーザー tottoripapertottoripaper
提出日時 2015-07-02 18:44:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,576 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 42,860 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-22 05:33:49
合計ジャッジ時間 5,457 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <algorithm>

int c1[100001], c_1[100001], c0;
int _c1[100001], _c_1[100001];

int count(int c1[100001], int c_1[100001], int c0){
    int res = 0;

    puts("wa-i");
    for(int i=100000,j=100000;i>0;i--){
        if(c1[i] == 0){continue;}

        if(j >= 0){
            while(j > 0 && (j >= i || c_1[j] == 0)){j -= 1;}
            if(j == 0){
                res += std::min(c1[i], c0);
                c0 -= std::min(c1[i], c0);
                if(c0 == 0){j = -1;}
            }else{
                res += std::min(c1[i], c_1[j]);
                c_1[j] -= std::min(c1[i], c_1[j]);
            }
        }else{
            while(-j < i && c1[-j] == 0){j += 1;}
            if(-j == i){continue;}
            res += std::min(c1[i], c1[-j]);
            c1[-j] -= std::min(c1[i], c1[-j]);
        }
    }

    return res;
}
                                                   

int main(){
    int N;
    scanf("%d", &N);

    c0 = 0;
    for(int i=0;i<2*N;i++){
        int a;
        scanf("%d", &a);

        if(a > 0){
            c1[a] += 1;
        }else if(a == 0){
            c0 += 1;
        }else{
            c_1[-a] += 1;
        }
    }

    int dry, wet, moist = c0 / 2;
    for(int i=1;i<=100000;i++){
        moist += std::min(c1[i], c_1[i]);
    }

    std::copy(c1, c1+100001, _c1);
    std::copy(c_1, c_1+100001, _c_1);
    dry = count(_c_1, _c1, c0);

    std::copy(c1, c1+100001, _c1);
    std::copy(c_1, c_1+100001, _c_1);
    wet = count(_c1, _c_1, c0);    

    printf("%d %d %d\n", dry, wet, moist);
}
0