結果

問題 No.1120 Strange Teacher
ユーザー tailstails
提出日時 2020-07-22 22:04:02
言語 Perl
(5.40.0)
結果
WA  
実行時間 -
コード長 320 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 6,812 KB
実行使用メモリ 33,024 KB
最終ジャッジ日時 2024-06-22 18:05:28
合計ジャッジ時間 3,200 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::u" used only once: possible typo at Main.pl line 21.
Main.pl syntax OK

ソースコード

diff #

sub muri { print -1; exit; }

$n=<>;
@a=<>=~/\S+/g;
@b=<>=~/\S+/g;
for(0..$n-1){
	$s-=$b[$_]-=$a[$_];
}

if($n==2){
	$s==0 or muri;
	$t=abs$b[0];
}else{
	$s%($n-2)==0 or muri;
	$s/=$n-2;
	if($b[0]+$s&1){
		$d=$n-2;
	}
	for(0..$n-1){
		($b[$_]+=$d)+$s&1 and muri;
		$t+=$u=($b[$_]+$s)/2;
	}
	$s==$t or muri;
}

print $t;
0