結果
問題 | No.1120 Strange Teacher |
ユーザー | chineristAC |
提出日時 | 2020-07-22 21:33:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 78 ms / 1,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 82,208 KB |
実行使用メモリ | 103,360 KB |
最終ジャッジ日時 | 2024-06-22 14:03:42 |
合計ジャッジ時間 | 3,239 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) S=sum(A)-sum(B) if N==2: if S==0: print(abs(A[0]-B[0])) exit() else: print(-1) exit() if S%(N-2)!=0: print(-1) exit() else: Q=S//(N-2) if Q<0: print(-1) exit() else: check=0 for i in range(N): a=A[i]-Q b=B[i] if a>b or (b-a)%2==1: print(-1) exit() else: check+=(b-a)//2 if check==Q: print(Q) exit() else: print(-1) exit()