結果

問題 No.54 Happy Hallowe'en
ユーザー KudeKude
提出日時 2020-09-07 02:18:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 1,910 ms
コンパイル使用メモリ 170,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-06 21:43:54
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 7 ms
6,944 KB
testcase_05 AC 11 ms
6,940 KB
testcase_06 AC 15 ms
6,940 KB
testcase_07 AC 24 ms
6,944 KB
testcase_08 AC 32 ms
6,944 KB
testcase_09 AC 42 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 WA -
testcase_13 AC 42 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

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>;

int n;
int vo[10000], to[10000], v[10000], t[10000];
int idx[10000];
bool dp[20001] = {true};

bool cmp(int x, int y) {return t[x] < t[y];}

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