結果

問題 No.710 チーム戦
ユーザー lapilapi
提出日時 2019-08-10 18:50:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 3,000 ms
コード長 1,226 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 106,332 KB
実行使用メモリ 42,428 KB
最終ジャッジ日時 2023-09-26 23:32:55
合計ジャッジ時間 3,040 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 29 ms
22,792 KB
testcase_03 AC 30 ms
23,120 KB
testcase_04 AC 32 ms
24,312 KB
testcase_05 AC 29 ms
22,188 KB
testcase_06 AC 30 ms
23,224 KB
testcase_07 AC 32 ms
23,604 KB
testcase_08 AC 32 ms
24,544 KB
testcase_09 AC 31 ms
23,376 KB
testcase_10 AC 28 ms
21,444 KB
testcase_11 AC 30 ms
22,988 KB
testcase_12 AC 32 ms
24,436 KB
testcase_13 AC 31 ms
23,848 KB
testcase_14 AC 31 ms
23,940 KB
testcase_15 AC 28 ms
21,740 KB
testcase_16 AC 32 ms
24,556 KB
testcase_17 AC 27 ms
21,496 KB
testcase_18 AC 30 ms
23,376 KB
testcase_19 AC 32 ms
24,204 KB
testcase_20 AC 29 ms
22,464 KB
testcase_21 AC 31 ms
23,836 KB
testcase_22 AC 57 ms
42,428 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 55 ms
40,816 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int A[109], B[109];
int dp[109][100009]; // dp[i][j] : j秒かけて1からi番目までのうちのいくつかを解いたときの、浮いた時間の最大値

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	int btot = 0;
	int atot = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i];
		atot += A[i];
		btot += B[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= atot; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); // A君がi+1番目の問題を解かない
			if(j+A[i+1] <= atot) dp[i + 1][j + A[i + 1]] = max(dp[i + 1][j + A[i + 1]], dp[i][j] + B[i + 1]); // A君がi+1番目の問題を解いた場合
		}
	}

	int ans = INF;
	for (int i = 0; i <= atot; i++) {
		int T = max(i, btot - dp[N][i]);
		ans = min(ans, T);
	}

	cout << ans << endl;

	return 0;
}
0