結果

問題 No.798 コレクション
ユーザー kotatsugamekotatsugame
提出日時 2019-03-15 22:29:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 555 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 78,236 KB
実行使用メモリ 8,812 KB
最終ジャッジ日時 2023-09-14 13:46:26
合計ジャッジ時間 2,282 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 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 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 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 2 ms
4,376 KB
testcase_13 AC 6 ms
7,384 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 5 ms
7,472 KB
testcase_17 AC 6 ms
7,384 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:18:61: 警告: iteration 700 invokes undefined behavior [-Waggressive-loop-optimizations]
   18 |         for(int i=0;i<=n;i++)for(int j=0;j<=700;j++)dp[i][j]=1e9;
      |                                                     ~~~~~~~~^~~~
main.cpp:18:43: 備考: within this loop
   18 |         for(int i=0;i<=n;i++)for(int j=0;j<=700;j++)dp[i][j]=1e9;
      |                                          ~^~~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
vector<pair<int,int> >a;
int 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]=1e9;
	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+a[i].first*(i-j));
		}
	}
	cout<<dp[n][n/3]<<endl;
}
0