結果

問題 No.2806 Cornflake Man
ユーザー tailstails
提出日時 2024-07-17 13:36:32
言語 cLay
(20240714-1)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 7,091 ms
コンパイル使用メモリ 208,952 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-07-17 20:28:36
合計ジャッジ時間 7,030 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,272 KB
testcase_01 AC 10 ms
6,912 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 11 ms
7,040 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 15 ms
7,552 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 8 ms
5,760 KB
testcase_10 AC 7 ms
5,504 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 10 ms
5,632 KB
testcase_13 AC 17 ms
7,680 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 21 ms
10,240 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int@n,@m,@a[n],b[],z=0;
sortA(n,a);
LHeap<int>h;
h.malloc(n,1);
rep(i,1,n){
	bool f=false;
	while(h.size){
		int j=h.hp[0];
		int v=h.val[j];
		if(v>a[i]){
			break;
		}
		if(v<a[i]){
			wt(-1);
			exit(0);
		}
		f=true;
		if(v+b[j]<=m){
			h.change(j,v+b[j]);
		}else{
			h.pop();
		}
	}
	if(!f){
		b[z]=a[i];
		h.change(z,2b[z]);
		++z;
	}
}
if(h.size){
	int j=h.hp[0];
	int v=h.val[j];
	if(v<=m){
		wt(-1);
		exit(0);
	}
}
wt(z);
wt(b(z));
0