結果

問題 No.54 Happy Hallowe'en
ユーザー nebukuro09nebukuro09
提出日時 2017-03-17 13:22:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 151,060 KB
実行使用メモリ 395,284 KB
最終ジャッジ日時 2023-09-17 19:21:12
合計ジャッジ時間 20,315 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 264 ms
394,596 KB
testcase_01 AC 284 ms
394,720 KB
testcase_02 AC 246 ms
394,780 KB
testcase_03 AC 251 ms
394,780 KB
testcase_04 AC 434 ms
394,884 KB
testcase_05 AC 660 ms
394,944 KB
testcase_06 AC 953 ms
395,284 KB
testcase_07 AC 1,436 ms
395,044 KB
testcase_08 AC 2,150 ms
395,148 KB
testcase_09 AC 2,928 ms
395,184 KB
testcase_10 AC 222 ms
394,804 KB
testcase_11 AC 222 ms
394,592 KB
testcase_12 AC 2,052 ms
395,224 KB
testcase_13 AC 3,192 ms
395,188 KB
testcase_14 AC 222 ms
394,600 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 224 ms
394,888 KB
testcase_18 AC 222 ms
394,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)

int N, T_MAX;
vector<pair<int, int> > VT;
int mem[10010][10010];

int dp(int n, int v) {
    if (n >= N) return v;
    if (v >= T_MAX) return v;
    if (mem[n][v] >= 0) return mem[n][v];
    if (v >= VT[n].first) return mem[n][v] = dp(n+1, v);
    else return mem[n][v] = max(dp(n+1, v), dp(n+1, v+VT[n].second));
}

int main() {
    cin >> N;
    REP(i, N) {
        int v, t;
        cin >> v >> t;
        VT.push_back(make_pair(t, v));
    }

    sort(VT.begin(), VT.end());
    T_MAX = VT[N-1].first;
    REP(i, 10010) REP(j, 10010) mem[i][j] = -1;
    cout << dp(0, 0) << endl;
}
0