結果
問題 | No.1120 Strange Teacher |
ユーザー |
|
提出日時 | 2020-07-22 23:20:06 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 778 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 25,300 KB |
最終ジャッジ日時 | 2024-06-23 01:05:17 |
合計ジャッジ時間 | 3,244 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 |
ソースコード
n = int(input())a = list(map(int,input().split()))b = list(map(int,input().split()))sa = sum(a)sb = sum(b)if n == 2:dif = a[0]-b[0]if a[1]+dif == b[1]:print(abs(dif))else:print(-1)exit()if sb > sa or (sa-sb)%(n-2) != 0:print(-1)else:count = (sa-sb)//(n-2)x = 0for i in range(n):dif = a[i]-b[i]if dif == count:continueif dif >= 0:if (count-dif)%2:print(-1)exit()x += (count-dif)//2else:if (count+dif)%2:print(-1)exit()x += -dif + (count+dif)//2if x == count:print(count)else:print(-1)