結果

問題 No.1120 Strange Teacher
ユーザー tailstails
提出日時 2020-07-22 22:14:59
言語 Perl
(5.38.2)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 323 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 5,220 KB
実行使用メモリ 32,180 KB
最終ジャッジ日時 2023-09-04 21:10:40
合計ジャッジ時間 3,761 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,800 KB
testcase_01 AC 3 ms
4,676 KB
testcase_02 AC 4 ms
4,824 KB
testcase_03 AC 15 ms
7,268 KB
testcase_04 AC 133 ms
31,996 KB
testcase_05 AC 131 ms
32,064 KB
testcase_06 AC 131 ms
32,044 KB
testcase_07 AC 131 ms
32,020 KB
testcase_08 AC 132 ms
31,868 KB
testcase_09 AC 2 ms
4,568 KB
testcase_10 AC 102 ms
29,048 KB
testcase_11 AC 100 ms
28,904 KB
testcase_12 AC 102 ms
28,908 KB
testcase_13 AC 101 ms
28,704 KB
testcase_14 AC 101 ms
29,000 KB
testcase_15 AC 101 ms
28,964 KB
testcase_16 AC 101 ms
28,956 KB
testcase_17 AC 101 ms
28,788 KB
testcase_18 AC 2 ms
4,568 KB
testcase_19 AC 130 ms
32,180 KB
testcase_20 AC 2 ms
4,664 KB
testcase_21 AC 3 ms
4,856 KB
testcase_22 AC 3 ms
4,660 KB
testcase_23 AC 2 ms
4,804 KB
testcase_24 AC 128 ms
31,676 KB
testcase_25 AC 3 ms
4,540 KB
testcase_26 AC 3 ms
4,680 KB
testcase_27 AC 2 ms
4,660 KB
testcase_28 AC 3 ms
4,832 KB
testcase_29 AC 2 ms
4,808 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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>=0 or muri;
	$s%($n-2)==0 or muri;
	$s/=$n-2;
	for(0..$n-1){
		$b[$_]+=$s;
		$b[$_]>=0 or muri;
		$b[$_]&1 and muri;
		$t+=$b[$_]/2;
	}
	$s==$t or muri;
}

print $t;
0