結果

問題 No.1997 X Lighting
ユーザー tailstails
提出日時 2022-08-19 15:14:11
言語 cLay
(20240104-1)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 6,285 ms
コンパイル使用メモリ 209,024 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 19:51:36
合計ジャッジ時間 7,506 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 6 ms
5,760 KB
testcase_14 AC 11 ms
6,528 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 6 ms
5,376 KB
testcase_17 AC 14 ms
6,656 KB
testcase_18 AC 7 ms
5,376 KB
testcase_19 AC 16 ms
6,784 KB
testcase_20 AC 16 ms
6,784 KB
testcase_21 AC 16 ms
6,784 KB
testcase_22 AC 15 ms
6,912 KB
testcase_23 AC 9 ms
5,760 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 15 ms
6,784 KB
testcase_26 AC 13 ms
6,400 KB
testcase_27 AC 14 ms
6,656 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 5 ms
5,376 KB
testcase_30 AC 15 ms
6,656 KB
testcase_31 AC 10 ms
6,016 KB
testcase_32 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n,@m,u[m],v[];
rep(i,m){
	ll@x,@y;
	u[i]=x+y-1;
	v[i]=x-y;
}
ll c=0;
int mu=m;
Unique(mu,u);
int mv=m;
Unique(mv,v);
rep(j,mv) c+=n-abs(v[j]);
ll mc=bsearch_min[ll,j,0,mv](v[j]>=0);
if(1){
	ll j=mc-1,k=mc;
	ll a[2]{0,0};
	rep(i,mu){
		ll un=u[i];
		if(un>=n) break;
		c+=un;
		while(j>=0&&un+v[j]>0) ++a[v[j]&1],--j;
		while(k<mv&&un-v[k]>0) ++a[v[k]&1],++k;
		c-=a[un&1^1];
	}
}
if(1){
	ll j=mc-1,k=mc;
	ll a[2]{0,0};
	rrep(i,mu){
		ll un=2n-u[i];
		if(un>n) break;
		c+=un;
		while(j>=0&&un+v[j]>0) ++a[v[j]&1],--j;
		while(k<mv&&un-v[k]>0) ++a[v[k]&1],++k;
		c-=a[un&1^1];
	}
}
wt(c);
0