結果

問題 No.54 Happy Hallowe'en
ユーザー a5uaa5ua
提出日時 2014-11-05 00:08:39
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 560 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 69,600 KB
実行使用メモリ 15,608 KB
最終ジャッジ日時 2023-08-29 00:37:54
合計ジャッジ時間 2,405 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
15,100 KB
testcase_01 AC 6 ms
15,088 KB
testcase_02 AC 6 ms
15,068 KB
testcase_03 AC 6 ms
15,052 KB
testcase_04 AC 22 ms
15,300 KB
testcase_05 AC 35 ms
15,184 KB
testcase_06 AC 51 ms
15,304 KB
testcase_07 AC 74 ms
15,304 KB
testcase_08 AC 97 ms
15,300 KB
testcase_09 AC 126 ms
15,380 KB
testcase_10 AC 6 ms
15,392 KB
testcase_11 AC 6 ms
15,108 KB
testcase_12 AC 146 ms
15,336 KB
testcase_13 AC 125 ms
15,608 KB
testcase_14 AC 6 ms
15,132 KB
testcase_15 AC 6 ms
15,308 KB
testcase_16 WA -
testcase_17 AC 6 ms
15,016 KB
testcase_18 AC 6 ms
15,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<bool> dp(10000 * 10000 + 1, false);
	vector<pair<int, int>> v(N);
	for (int n = 0; n < N; ++n) {
		cin >> v[n].first >> v[n].second;
	}
	sort(v.begin(), v.end());
	dp[0] = true;

	int ans = 0;
	for (int n = 0; n < N; ++n) {
		int V = v[n].first;
		int T = v[n].second;
		for (int i = T - 1; i >= 0; --i) {
			if (dp[i]) {
				dp[i + V] = true;
				ans = max(ans, i + V);
			}
		}
	}
	cout << ans << endl;
}
0