結果

問題 No.2248 max(C)-min(C)
ユーザー tailstails
提出日時 2023-03-17 23:17:01
言語 cLay
(20241019-1)
結果
AC  
実行時間 102 ms / 3,000 ms
コード長 337 bytes
コンパイル時間 3,045 ms
コンパイル使用メモリ 175,768 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-09-18 12:20:06
合計ジャッジ時間 5,710 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n,@a[n],@b[];
Heap<pair<ll,pair<ll,ll>>>h;
h.malloc(n);
ll mx=0;
rep(i,n){
	ll x=min(a[i],b[i]);
	h.push({x,{abs(a[i]-b[i])>>1,2}});
	mx>?=x;
}
ll z=mx;
while(true){
	auto c=h.pop();
	z<?=mx-c.first;
	if(c.second.second==0){
		break;
	}
	ll x=c.first+c.second.first;
	h.push({x,{c.second.first,c.second.second-1}});
	mx>?=x;
}
wt(z);
0