結果
| 問題 |
No.1584 Stones around Circle Pond
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2021-07-03 00:43:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 992 bytes |
| コンパイル時間 | 1,294 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 52,608 KB |
| 最終ジャッジ日時 | 2024-06-29 14:09:09 |
| 合計ジャッジ時間 | 4,014 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 58 |
ソースコード
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)
Kude