結果

問題 No.974 最後の日までに
ユーザー kotatsugamekotatsugame
提出日時 2020-01-18 00:36:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 929 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 84,112 KB
実行使用メモリ 9,156 KB
最終ジャッジ日時 2023-09-08 10:06:47
合計ジャッジ時間 3,814 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
8,816 KB
testcase_01 AC 34 ms
7,508 KB
testcase_02 AC 34 ms
9,156 KB
testcase_03 AC 35 ms
8,056 KB
testcase_04 AC 34 ms
8,200 KB
testcase_05 AC 30 ms
8,148 KB
testcase_06 AC 31 ms
8,668 KB
testcase_07 AC 30 ms
8,900 KB
testcase_08 AC 30 ms
8,676 KB
testcase_09 AC 31 ms
8,584 KB
testcase_10 AC 31 ms
8,876 KB
testcase_11 AC 31 ms
7,244 KB
testcase_12 AC 31 ms
7,672 KB
testcase_13 AC 32 ms
8,572 KB
testcase_14 AC 31 ms
7,560 KB
testcase_15 AC 33 ms
8,204 KB
testcase_16 WA -
testcase_17 AC 36 ms
8,312 KB
testcase_18 AC 36 ms
7,296 KB
testcase_19 AC 35 ms
7,744 KB
testcase_20 AC 36 ms
7,796 KB
testcase_21 AC 36 ms
7,740 KB
testcase_22 AC 35 ms
7,512 KB
testcase_23 WA -
testcase_24 AC 35 ms
7,568 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 31 ms
8,204 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 36 ms
7,240 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 21 ms
5,300 KB
testcase_34 AC 32 ms
7,856 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 22 ms
9,132 KB
testcase_41 AC 29 ms
7,592 KB
testcase_42 WA -
testcase_43 AC 37 ms
8,940 KB
testcase_44 WA -
testcase_45 AC 23 ms
5,164 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:18:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   18 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int W;
long A[55],B[55],C[55];
vector<pair<long,long> >X;
void dfs(int d,int lim,long x,long y)
{
	if(d==lim)
	{
		X.push_back(make_pair(y,x));
		return;
	}
	dfs(d+1,lim,x,y+A[d]);
	if(d+2<=lim)dfs(d+2,lim,x+B[d+1],y-C[d+1]);
}
main()
{
	cin>>W;
	for(int i=0;i<W;i++)cin>>A[i]>>B[i]>>C[i];
	if(W==1)
	{
		cout<<0<<endl;
		return 0;
	}
	long ans=0;
	for(int mid:(vector<int>){W/2})
	{
		dfs(0,mid,0,0);
		sort(X.rbegin(),X.rend());
		vector<pair<long,long> >A;
		long pre=-1;
		for(pair<long,long>p:X)
		{
			if(pre<p.second)
			{
				pre=p.second;
				A.push_back(p);
			}
		}
		sort(A.begin(),A.end());
		X.clear();
		dfs(mid,W,0,0);
		for(pair<long,long>p:X)
		{
			vector<pair<long,long> >::iterator it=lower_bound(A.begin(),A.end(),make_pair(-p.first,0L));
			if(it!=A.end())ans=max(ans,p.second+it->second);
		}
		X.clear();
	}
	cout<<ans<<endl;
}
0