結果

問題 No.54 Happy Hallowe'en
ユーザー KudeKude
提出日時 2020-09-07 04:01:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 781 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 167,248 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 16:19:26
合計ジャッジ時間 2,625 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; --i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

struct C {
    int t;
    int v;
};

int n;
C vt[10000];
bool dp[20001] = {true};

bool cmp(C x, C y) {return x.t+x.v < y.t+y.v;}

int main() {
    scanf("%d", &n);
    rep(i, n) {
        scanf("%d%d", &vt[i].v, &vt[i].t);
    }
    sort(vt, vt + n, cmp);
    rep(i, n) {
        int vi = vt[i].v;
        rrep(j, vt[i].t) dp[j + vi] |= dp[j];
    }
    rrep(i, 20001) if (dp[i]) {
        cout << i << endl;
        return 0;
    }
}
0