結果

問題 No.54 Happy Hallowe'en
ユーザー kimiyukikimiyuki
提出日時 2017-01-03 20:05:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 975 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 10:34:56
合計ジャッジ時間 2,117 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <memory>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> v(n), t(n); repeat (i,n) cin >> v[i] >> t[i];
    vector<int> ix(n); whole(iota, ix, 0);
    whole(iota, ix, 0);
    whole(sort, ix, [&](int i, int j) { return v[i] + t[i] < v[j] + t[j]; });
    auto dp = make_unique<bitset<2*10000+1> >();
    (*dp)[0] = true;
    for (int i : ix) {
        auto it = make_unique<bitset<2*10000+1> >();
        it->flip();
        *it <<= t[i];
        it->flip();
        *it &= *dp;
        *it <<= v[i];
        *dp |= *it;
    }
    for (int i = dp->size() - 1; i >= 0; -- i) {
        if ((*dp)[i]) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}
0