結果

問題 No.710 チーム戦
ユーザー minato
提出日時 2020-03-17 08:07:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 37 ms / 3,000 ms
コード長 1,112 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 179,864 KB
実行使用メモリ 43,392 KB
最終ジャッジ日時 2024-11-29 20:31:46
合計ジャッジ時間 4,005 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int dp[101][101010];
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N; cin >> N;
	vector<int> A(N),B(N);
	rep(i,N) cin >> A[i] >> B[i];

	rep(i,N+1) rep(j,101010) dp[i][j] = 1e9;
	dp[0][0] = 0;
	rep(i,N) {
		rep(j,100001) {
			chmin(dp[i+1][j],dp[i][j]+B[i]);
			if (j < A[i]) continue;
			chmin(dp[i+1][j],dp[i][j-A[i]]);
		}
	}
	int ans = 1e9;
	rep(j,100001) {
		chmin(ans,max(j,dp[N][j]));
	}

	cout << ans << ln;
}
0