結果

問題 No.54 Happy Hallowe'en
ユーザー PachicobuePachicobue
提出日時 2018-11-21 03:17:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 205,228 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 02:33:45
合計ジャッジ時間 3,931 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 24 ms
4,384 KB
testcase_05 AC 41 ms
4,384 KB
testcase_06 AC 60 ms
4,380 KB
testcase_07 AC 93 ms
4,380 KB
testcase_08 AC 123 ms
4,380 KB
testcase_09 AC 161 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 161 ms
4,380 KB
testcase_13 AC 160 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
int main()
{
    int N;
    std::cin >> N;
    using P = std::pair<int, int>;
    std::vector<P> D(N);
    for (int i = 0; i < N; i++) { std::cin >> D[i].first >> D[i].second; }
    std::sort(D.begin(), D.end(), [](const P& p1, const P& p2) { return p1.first + p1.second < p2.first + p2.second; });
    std::bitset<20001> dp;
    dp[0] = true;
    for (const auto& p : D) {
        for (int i = 0; i < p.second; i++) { dp[i + p.first] = dp[i] | dp[i + p.first]; }
    }
    for (int i = 20000; i >= 0; i--) {
        if (dp[i]) { return std::cout << i << std::endl, 0; }
    }
    return 0;
}
0