結果

問題 No.1120 Strange Teacher
ユーザー chineristACchineristAC
提出日時 2020-07-22 21:33:04
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 658 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 101,236 KB
最終ジャッジ日時 2023-09-04 15:43:56
合計ジャッジ時間 5,181 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,096 KB
testcase_01 AC 76 ms
71,452 KB
testcase_02 AC 82 ms
75,760 KB
testcase_03 AC 89 ms
76,448 KB
testcase_04 AC 120 ms
101,164 KB
testcase_05 AC 116 ms
100,976 KB
testcase_06 AC 118 ms
101,184 KB
testcase_07 AC 117 ms
101,232 KB
testcase_08 AC 118 ms
101,208 KB
testcase_09 AC 77 ms
71,404 KB
testcase_10 AC 121 ms
101,092 KB
testcase_11 AC 120 ms
101,136 KB
testcase_12 AC 122 ms
100,932 KB
testcase_13 AC 123 ms
101,236 KB
testcase_14 AC 121 ms
101,128 KB
testcase_15 AC 120 ms
100,980 KB
testcase_16 AC 116 ms
101,156 KB
testcase_17 AC 117 ms
100,936 KB
testcase_18 AC 75 ms
71,300 KB
testcase_19 AC 119 ms
99,608 KB
testcase_20 AC 77 ms
71,288 KB
testcase_21 AC 77 ms
71,280 KB
testcase_22 AC 77 ms
71,412 KB
testcase_23 AC 76 ms
71,388 KB
testcase_24 AC 116 ms
100,316 KB
testcase_25 AC 77 ms
71,308 KB
testcase_26 AC 76 ms
71,408 KB
testcase_27 AC 76 ms
71,216 KB
testcase_28 AC 78 ms
71,256 KB
testcase_29 AC 75 ms
71,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
0