結果

問題 No.1583 Building Blocks
ユーザー uzzyuzzy
提出日時 2021-07-03 04:59:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,167 bytes
コンパイル時間 2,456 ms
コンパイル使用メモリ 186,004 KB
実行使用メモリ 7,236 KB
最終ジャッジ日時 2023-10-12 03:04:55
合計ジャッジ時間 4,210 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
5,224 KB
testcase_04 AC 3 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
5,408 KB
testcase_07 AC 4 ms
5,524 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 6 ms
6,876 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 4 ms
5,752 KB
testcase_13 AC 5 ms
6,284 KB
testcase_14 AC 4 ms
4,960 KB
testcase_15 AC 4 ms
5,808 KB
testcase_16 AC 5 ms
6,300 KB
testcase_17 AC 5 ms
5,936 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 7 ms
7,236 KB
testcase_20 AC 3 ms
4,860 KB
testcase_21 AC 3 ms
4,724 KB
testcase_22 AC 3 ms
4,832 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 5 ms
6,248 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 6 ms
6,516 KB
testcase_27 AC 3 ms
4,836 KB
testcase_28 AC 6 ms
6,732 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 5 ms
6,288 KB
testcase_32 AC 3 ms
5,312 KB
testcase_33 AC 6 ms
7,228 KB
testcase_34 AC 2 ms
4,352 KB
testcase_35 AC 3 ms
5,400 KB
testcase_36 AC 5 ms
6,692 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 1 ms
4,352 KB
testcase_39 AC 2 ms
4,352 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 2 ms
4,352 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 1 ms
4,348 KB
testcase_45 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
//#include<atcoder/all>
//using namespace atcoder;


using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int dp[1001][1001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;

	pair<int, int> WS[1000];
	rep(i, N) {
		int w, s;
		cin >> w >> s;
		WS[i] = { s+w,w };
	}
	sort(WS, WS + N);
	reverse(WS, WS + N);

	rep(i, N + 1) rep(j, N + 1) dp[i][j] = -1;
	dp[0][0] = 2.1e9;
	rep(i, N) {
		rep(j, N) {
			chmax(dp[i + 1][j], dp[i][j]);
			if (dp[i][j] >= 0) chmax(dp[i + 1][j + 1], min(dp[i][j] - WS[i].second, WS[i].first - WS[i].second));
		}
	}
	int kotae = 0;
	rep1(j, N) if (dp[N][j] >= 0) kotae = j;

	co(kotae);

	Would you please return 0;
}
0