結果
問題 |
No.1120 Strange Teacher
|
ユーザー |
![]() |
提出日時 | 2024-04-11 13:26:07 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 135 ms / 1,000 ms |
コード長 | 445 bytes |
コンパイル時間 | 93 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 24,868 KB |
最終ジャッジ日時 | 2024-10-02 21:34:37 |
合計ジャッジ時間 | 3,457 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) D=[a-b for a,b in zip(A,B)] if N==2: if sum(D)==0: ans=abs(A[0]-B[0]) else: ans=-1 else: if sum(D)<0 or sum(D)%(N-2): ans=-1 else: cnt=sum(D)//(N-2) for i in range(N): A[i]-=cnt if all(a<=b and a%2==b%2 for a,b in zip(A,B)): ans=cnt else: ans=-1 print(ans)