結果
問題 | No.710 チーム戦 |
ユーザー |
![]() |
提出日時 | 2019-08-10 18:50:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 3,000 ms |
コード長 | 1,226 bytes |
コンパイル時間 | 995 ms |
コンパイル使用メモリ | 107,236 KB |
実行使用メモリ | 42,496 KB |
最終ジャッジ日時 | 2024-07-19 17:16:59 |
合計ジャッジ時間 | 2,829 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#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; }