結果

問題 No.54 Happy Hallowe'en
ユーザー KudeKude
提出日時 2020-09-07 02:20:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 2,592 ms
コンパイル使用メモリ 167,712 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 14:39:27
合計ジャッジ時間 2,813 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 12 ms
4,380 KB
testcase_06 AC 17 ms
4,376 KB
testcase_07 AC 25 ms
4,380 KB
testcase_08 AC 32 ms
4,384 KB
testcase_09 AC 42 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 41 ms
4,380 KB
testcase_13 AC 41 ms
4,384 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 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>;

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 to[x] < to[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