結果

問題 No.2248 max(C)-min(C)
ユーザー tails
提出日時 2023-03-17 23:10:50
言語 cLay
(20241019-1)
結果
AC  
実行時間 98 ms / 3,000 ms
コード長 362 bytes
コンパイル時間 3,244 ms
コンパイル使用メモリ 176,000 KB
実行使用メモリ 16,244 KB
最終ジャッジ日時 2024-09-18 12:15:34
合計ジャッジ時間 6,501 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n,@a[n],@b[];
Heap<pair<ll,pair<ll,ll>>>h;
h.malloc(n);
ll mn=1d9,mx=0;
rep(i,n){
	ll x=min(a[i],b[i]);
	h.push({x,{abs(a[i]-b[i])>>1,2}});
	mn<?=x;
	mx>?=x;
}
ll z=mx-mn;
while(true){
	auto c=h.pop();
	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;
	z<?=mx-h.top().first;
}
wt(z);
0