結果

問題 No.798 コレクション
ユーザー pockynypockyny
提出日時 2019-03-16 03:41:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 1,012 ms
コンパイル使用メモリ 71,016 KB
実行使用メモリ 34,932 KB
最終ジャッジ日時 2023-09-14 15:01:30
合計ジャッジ時間 1,930 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 13 ms
25,716 KB
testcase_14 AC 17 ms
30,000 KB
testcase_15 AC 16 ms
27,876 KB
testcase_16 AC 9 ms
21,380 KB
testcase_17 AC 14 ms
25,780 KB
testcase_18 AC 21 ms
34,128 KB
testcase_19 AC 18 ms
31,968 KB
testcase_20 AC 10 ms
21,428 KB
testcase_21 AC 9 ms
19,532 KB
testcase_22 AC 16 ms
27,868 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 22 ms
34,912 KB
testcase_25 AC 22 ms
34,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
pair<ll,ll> p[2010];
ll dp[2010][2010] = {};
int main(){
	ll i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		ll a,b; cin >> a >> b;
		p[i] = {-b,a};
	}
	sort(p,p+n);
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			dp[i][j] = 10000000000000000;
		}
	}
	dp[0][0] = 0;
	for(i=1;i<=n;i++){
		for(j=0;j<=n;j++){
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			dp[i][j+1] = min(dp[i][j+1],dp[i-1][j] + p[i-1].second - p[i-1].first*j);
		}
	}
	cout << dp[n][n - n/3] << endl;
}
0