結果

問題 No.2370 He ate many cakes
ユーザー tailstails
提出日時 2023-07-03 21:17:24
言語 cLay
(20240104-1)
結果
TLE  
実行時間 -
コード長 322 bytes
コンパイル時間 4,233 ms
コンパイル使用メモリ 172,792 KB
実行使用メモリ 129,724 KB
最終ジャッジ日時 2023-09-24 18:22:51
合計ジャッジ時間 15,958 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1,011 ms
84,344 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 57 ms
13,676 KB
testcase_11 AC 287 ms
30,600 KB
testcase_12 AC 1,011 ms
66,048 KB
testcase_13 AC 1,785 ms
119,256 KB
testcase_14 AC 467 ms
44,708 KB
testcase_15 TLE -
testcase_16 AC 1,739 ms
109,124 KB
testcase_17 TLE -
testcase_18 AC 161 ms
15,144 KB
testcase_19 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n,@k,@a[n],o=0,t=0;
rep(i,n){
	if(a[i]<0){
		o+=a[i];
		a[i]=-a[i];
	}
	t+=a[i];
}
unordered_set<int>s;
priority_queue<pair<ll,int>>q;
q.push({t,0});
rep(k-1){
	auto b=q.top();
	q.pop();
	rep(i,n){
		int c=b.second|1<<i;
		if(c!=b.second&&s.insert(c).second){
			q.push({b.first-a[i],c});
		}
	}
}
wt(q.top().first+o);
0