結果

問題 No.2743 Twisted Lattice
ユーザー tailstails
提出日時 2024-04-21 10:06:07
言語 cLay
(20240104-1)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 6,404 ms
コンパイル使用メモリ 214,416 KB
実行使用メモリ 16,640 KB
最終ジャッジ日時 2024-04-21 10:06:16
合計ジャッジ時間 8,337 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
16,256 KB
testcase_01 WA -
testcase_02 AC 41 ms
16,384 KB
testcase_03 AC 39 ms
16,384 KB
testcase_04 AC 44 ms
16,640 KB
testcase_05 AC 44 ms
16,512 KB
testcase_06 AC 45 ms
16,640 KB
testcase_07 AC 44 ms
16,512 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@h,@w,@n,@(a,b)[n],c[],z[],pa,pb,q;
sortA_index(n,b,a,c);
pa=a[0];
pb=b[0];
q=pa-pb;
z[c[0]]=ll_inf;
rep(i,1,n){
	ll y;
	if(b[i]==b[i-1]){
		y=a[i]-a[i-1];
	}else{
		if(b[i]==pb+1){
			y=max(a[i],pa);
		}else{
			y=ll_inf;
		}
		y<?=q+a[i]+b[i]-2;
		pa=a[i];
		pb=b[i];
	}
	z[c[i]]=y;
	q<?=a[i]-b[i];
}
q=a[n-1]+b[n-1];
rrep(i,n-1){
	ll y=z[c[i]];
	if(b[i]==b[i+1]){
		y<?=a[i+1]-a[i];
	}else if(b[i]==b[i+1]-1){
		y<?=max(a[i],a[i+1]);
	}
	y<?=q+a[i]-b[i]-2;
	z[c[i]]=y;
	q<?=a[i]+b[i];
}
wtLn(z(n));
0