結果

問題 No.974 最後の日までに
ユーザー kotatsugamekotatsugame
提出日時 2020-01-18 00:30:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 970 ms
コンパイル使用メモリ 85,032 KB
実行使用メモリ 13,480 KB
最終ジャッジ日時 2023-09-08 09:55:58
合計ジャッジ時間 6,623 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
12,764 KB
testcase_01 AC 96 ms
11,632 KB
testcase_02 AC 96 ms
11,944 KB
testcase_03 AC 97 ms
12,376 KB
testcase_04 AC 95 ms
12,808 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 84 ms
12,324 KB
testcase_08 AC 85 ms
12,160 KB
testcase_09 AC 85 ms
12,308 KB
testcase_10 AC 85 ms
12,252 KB
testcase_11 AC 88 ms
11,740 KB
testcase_12 AC 88 ms
12,868 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 104 ms
11,904 KB
testcase_20 AC 103 ms
11,828 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 91 ms
11,840 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 WA -
testcase_34 AC 94 ms
11,724 KB
testcase_35 WA -
testcase_36 AC 2 ms
4,376 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
4,376 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 94 ms
12,884 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 2 ms
4,384 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 1 ms
4,376 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-1,W/2})
	{
		dfs(0,mid,0,0);
		sort(X.rbegin(),X.rend());
		vector<pair<long,long> >A;
		long pre=0;
		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);
		}
	}
	cout<<ans<<endl;
}
0