結果

問題 No.1584 Stones around Circle Pond
ユーザー KudeKude
提出日時 2021-07-03 00:43:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 992 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 71,288 KB
最終ジャッジ日時 2023-09-12 01:02:50
合計ジャッジ時間 6,841 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
70,872 KB
testcase_01 AC 69 ms
71,104 KB
testcase_02 AC 70 ms
70,876 KB
testcase_03 AC 69 ms
71,072 KB
testcase_04 AC 70 ms
71,056 KB
testcase_05 AC 69 ms
71,052 KB
testcase_06 AC 69 ms
71,096 KB
testcase_07 AC 69 ms
71,136 KB
testcase_08 AC 69 ms
70,760 KB
testcase_09 AC 68 ms
71,284 KB
testcase_10 AC 70 ms
71,180 KB
testcase_11 AC 70 ms
71,072 KB
testcase_12 AC 68 ms
71,116 KB
testcase_13 AC 69 ms
71,056 KB
testcase_14 AC 69 ms
71,056 KB
testcase_15 AC 68 ms
70,720 KB
testcase_16 AC 68 ms
71,208 KB
testcase_17 AC 73 ms
70,872 KB
testcase_18 AC 71 ms
71,288 KB
testcase_19 AC 68 ms
71,180 KB
testcase_20 AC 69 ms
71,056 KB
testcase_21 AC 69 ms
71,132 KB
testcase_22 AC 69 ms
70,684 KB
testcase_23 AC 68 ms
71,132 KB
testcase_24 AC 70 ms
70,684 KB
testcase_25 AC 70 ms
71,280 KB
testcase_26 AC 70 ms
70,780 KB
testcase_27 AC 68 ms
71,132 KB
testcase_28 AC 69 ms
71,104 KB
testcase_29 AC 68 ms
71,056 KB
testcase_30 AC 70 ms
71,128 KB
testcase_31 AC 68 ms
71,164 KB
testcase_32 AC 67 ms
71,136 KB
testcase_33 AC 70 ms
71,168 KB
testcase_34 AC 69 ms
71,216 KB
testcase_35 AC 69 ms
71,076 KB
testcase_36 AC 69 ms
71,164 KB
testcase_37 AC 69 ms
71,188 KB
testcase_38 AC 69 ms
70,956 KB
testcase_39 AC 68 ms
70,876 KB
testcase_40 AC 69 ms
70,952 KB
testcase_41 AC 69 ms
70,684 KB
testcase_42 AC 69 ms
71,128 KB
testcase_43 AC 69 ms
70,696 KB
testcase_44 AC 68 ms
70,696 KB
testcase_45 AC 67 ms
70,920 KB
testcase_46 AC 73 ms
71,104 KB
testcase_47 AC 71 ms
71,132 KB
testcase_48 AC 71 ms
71,260 KB
testcase_49 AC 71 ms
71,052 KB
testcase_50 AC 69 ms
71,056 KB
testcase_51 AC 70 ms
70,956 KB
testcase_52 AC 71 ms
71,060 KB
testcase_53 AC 70 ms
70,872 KB
testcase_54 AC 71 ms
71,132 KB
testcase_55 AC 70 ms
71,136 KB
testcase_56 AC 69 ms
71,132 KB
testcase_57 AC 69 ms
70,776 KB
testcase_58 AC 71 ms
71,056 KB
testcase_59 AC 70 ms
71,168 KB
testcase_60 AC 69 ms
70,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n, l = map(int, input().split())
    d = list(map(int, input().split()))
    d += [l + di for di in d]
    b = list(map(int, input().split()))
    s = sum(b)
    if s % (n * l):
        return False
    s //= n * l
    cnt = 0
    for i in range(n):
        c1 = b[i + 1] - b[i]
        c2 = b[i - 1] - b[i]
        c3 = b[(n + i + 1) % (2 * n)] - b[n + i]
        c4 = b[n + i - 1] - b[n + i]
        d1 = (d[i + 1] - d[i]) % (2 * l)
        d2 = (d[i] - d[i - 1]) % (2 * l)
        d3 = (d[(n + i + 1) % (2 * n)] - d[n + i]) % (2 * l)
        d4 = (d[n + i] - d[n + i - 1]) % (2 * l)
        if c1 % d1 or c2 % d2 or c3 % d3 or c4 % d4:
            return False
        c1 //= d1
        c2 //= d2
        c3 //= d3
        c4 //= d4
        if c1 + c2 != -(c3 + c4):
            return False
        c = abs(c1 + c2)
        if c % 2:
            return False
        cnt += c // 2
    s -= cnt
    return s >= 0 and s % 2 == 0

ans = 'Yes' if solve() else 'No'
print(ans)
0