結果
問題 | No.1120 Strange Teacher |
ユーザー |
![]() |
提出日時 | 2020-07-22 22:23:03 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 177 ms / 1,000 ms |
コード長 | 659 bytes |
コンパイル時間 | 100 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 24,928 KB |
最終ジャッジ日時 | 2024-06-22 18:56:35 |
合計ジャッジ時間 | 3,944 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) ans=0 for x in range(n): c=b[x]-a[x] ans+=c if n==2: if a[0]-b[0]==-1*(a[1]-b[1]): print(abs(a[0]-b[0])) else: print(-1) else: ans=ans*(-1) if ans%(n-2)==0: ans1=ans//(n-2) ch=0 out=0 for u in range(n): e=b[u]-a[u] if (e+ans1)%2==1: out+=1 elif e+ans1<0: out+=1 ch+=(e+ans1)//2 if out==0 and ch==ans1: print(ans1) else: print(-1) else: print(-1)