結果

問題 No.710 チーム戦
ユーザー kotatsugamekotatsugame
提出日時 2018-06-29 22:56:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 522 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 66,912 KB
実行使用メモリ 7,396 KB
最終ジャッジ日時 2023-09-13 15:32:15
合計ジャッジ時間 5,414 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100],b[100];
int dp[101][10010];
int f(int a[],int b[])
{
	int sum=0;
	for(int i=0;i<n;i++)sum+=a[i];
	for(int i=0;i<n;i++)
	{
		for(int k=0;k<=sum;k++)dp[i+1][k]=dp[i][k];
		for(int k=0;k<=sum-a[i]-b[i];k++)
		{
			dp[i+1][k+a[i]+b[i]]=max(dp[i+1][k+a[i]+b[i]],dp[i][k]+a[i]);
		}
	}
	int ans=0;
	for(int i=0;i<=sum;i++)ans=max(dp[n][i],ans);
	return sum-ans;
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	cout<<min(f(a,b),f(b,a))<<endl;
}
0