結果

問題 No.974 最後の日までに
ユーザー 👑 kmjpkmjp
提出日時 2020-01-18 02:20:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,884 bytes
コンパイル時間 1,857 ms
コンパイル使用メモリ 177,272 KB
実行使用メモリ 7,084 KB
最終ジャッジ日時 2023-09-08 12:33:56
合計ジャッジ時間 10,221 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
7,084 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 131 ms
6,992 KB
testcase_04 AC 130 ms
6,828 KB
testcase_05 AC 128 ms
6,988 KB
testcase_06 AC 128 ms
6,932 KB
testcase_07 AC 128 ms
6,812 KB
testcase_08 AC 128 ms
6,820 KB
testcase_09 AC 128 ms
6,824 KB
testcase_10 AC 127 ms
6,788 KB
testcase_11 AC 127 ms
6,932 KB
testcase_12 AC 127 ms
6,800 KB
testcase_13 AC 135 ms
6,916 KB
testcase_14 AC 136 ms
6,852 KB
testcase_15 AC 136 ms
6,888 KB
testcase_16 AC 137 ms
6,880 KB
testcase_17 AC 130 ms
6,988 KB
testcase_18 AC 131 ms
6,792 KB
testcase_19 AC 130 ms
6,792 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 130 ms
6,824 KB
testcase_24 AC 131 ms
6,796 KB
testcase_25 AC 113 ms
6,788 KB
testcase_26 AC 114 ms
6,840 KB
testcase_27 WA -
testcase_28 AC 131 ms
6,928 KB
testcase_29 AC 114 ms
6,780 KB
testcase_30 AC 134 ms
6,952 KB
testcase_31 AC 115 ms
6,812 KB
testcase_32 AC 114 ms
6,940 KB
testcase_33 AC 130 ms
6,992 KB
testcase_34 WA -
testcase_35 AC 113 ms
6,820 KB
testcase_36 AC 113 ms
6,920 KB
testcase_37 AC 132 ms
6,824 KB
testcase_38 AC 114 ms
6,984 KB
testcase_39 AC 113 ms
6,924 KB
testcase_40 AC 126 ms
6,832 KB
testcase_41 AC 126 ms
6,924 KB
testcase_42 AC 136 ms
6,884 KB
testcase_43 WA -
testcase_44 AC 134 ms
6,788 KB
testcase_45 AC 134 ms
6,948 KB
testcase_46 AC 113 ms
6,884 KB
testcase_47 AC 113 ms
6,916 KB
testcase_48 AC 113 ms
6,828 KB
testcase_49 AC 112 ms
6,832 KB
testcase_50 AC 113 ms
6,988 KB
testcase_51 AC 113 ms
6,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int W;
ll A[55],B[55],C[55];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>W;
	FOR(i,W) cin>>A[i]>>B[i]>>C[i];
	
	vector<pair<ll,ll>> cand[2];
	int mask;
	FOR(mask,1<<25) if((mask&(mask>>1))==0) {
		
		if(mask%2==0) {
			ll m=-C[26],s=B[26];
			for(i=27;i<52;i++) {
				if(mask&(1<<(i-26))) {
					i++;
					m-=C[i];
					s+=B[i];
				}
				else {
					m+=A[i];
				}
			}
			cand[1].push_back({m,s});
		}
		else {
			ll m=0,s=0;
			for(i=26;i<52;i++) {
				if(mask&(1<<(i-26))) {
					i++;
					m-=C[i];
					s+=B[i];
				}
				else {
					m+=A[i];
				}
			}
			cand[0].push_back({m,s});
		}
	}
	FOR(i,2) {
		sort(ALL(cand[i]));
		vector<pair<ll,ll>> CC;
		FORR(c,cand[i]) {
			while(CC.size() && CC.back().second<=c.second) CC.pop_back();
			CC.push_back(c);
		}
		cand[i]=CC;
		//cout<<i<<endl;
		//FORR(c,CC) cout<<c.first<<" "<<c.second<<endl;
	}
	ll ret=0;
	FOR(mask,1<<26) if((mask&(mask>>1))==0) {
		ll m=0,s=0;
		FOR(i,26) {
			if(mask&(1<<i)) {
				if(i==25) break;
				i++;
				m-=C[i];
				s+=B[i];
			}
			else {
				m+=A[i];
			}
		}
		i=26-i;
		x=lower_bound(ALL(cand[i]),make_pair(-m,0LL))-cand[i].begin();
		if(x<cand[i].size()) ret=max(ret,s+cand[i][x].second);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0