結果

問題 No.2743 Twisted Lattice
ユーザー tailstails
提出日時 2024-04-21 10:20:18
言語 cLay
(20240104-1)
結果
AC  
実行時間 46 ms / 3,000 ms
コード長 541 bytes
コンパイル時間 5,707 ms
コンパイル使用メモリ 213,452 KB
実行使用メモリ 16,640 KB
最終ジャッジ日時 2024-04-21 10:20:26
合計ジャッジ時間 7,603 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
16,384 KB
testcase_01 AC 44 ms
16,384 KB
testcase_02 AC 43 ms
16,512 KB
testcase_03 AC 40 ms
16,384 KB
testcase_04 AC 46 ms
16,640 KB
testcase_05 AC 46 ms
16,640 KB
testcase_06 AC 45 ms
16,512 KB
testcase_07 AC 45 ms
16,512 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 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];
}
pa=a[n-1];
pb=b[n-1];
q=pa+pb;
rrep(i,n-1){
	ll y=z[c[i]];
	if(b[i]==b[i+1]){
		y<?=a[i+1]-a[i];
	}else{
		pa=a[i+1];
		pb=b[i+1];
	}
	if(b[i]==pb-1){
		y<?=max(a[i],pa);
	}
	y<?=q+a[i]-b[i]-2;
	z[c[i]]=y;
	q<?=a[i]+b[i];
}
wtLn(z(n));
0