結果

問題 No.798 コレクション
ユーザー kotatsugamekotatsugame
提出日時 2019-03-15 22:30:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 78,488 KB
実行使用メモリ 14,312 KB
最終ジャッジ日時 2023-09-14 13:46:35
合計ジャッジ時間 1,810 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 7 ms
11,480 KB
testcase_14 AC 7 ms
13,508 KB
testcase_15 AC 8 ms
13,728 KB
testcase_16 AC 5 ms
9,412 KB
testcase_17 AC 6 ms
11,556 KB
testcase_18 AC 9 ms
14,076 KB
testcase_19 AC 8 ms
13,800 KB
testcase_20 AC 6 ms
9,512 KB
testcase_21 AC 5 ms
9,576 KB
testcase_22 AC 7 ms
13,540 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 9 ms
14,312 KB
testcase_25 AC 8 ms
14,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
vector<pair<int,int> >a;
long dp[2001][700];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int u,v;cin>>u>>v;
		a.push_back(make_pair(v,u));
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	for(int i=0;i<=n;i++)for(int j=0;j<700;j++)dp[i][j]=9e18;
	dp[0][0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=n/3;j++)
		{
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+a[i].second+1L*a[i].first*(i-j));
		}
	}
	cout<<dp[n][n/3]<<endl;
}
0