結果
問題 | No.343 手抜き工事のプロ |
ユーザー |
![]() |
提出日時 | 2020-12-11 00:48:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 20,416 KB |
最終ジャッジ日時 | 2024-09-19 21:00:26 |
合計ジャッジ時間 | 2,597 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
from itertools import accumulateimport sysinput = sys.stdin.buffer.readlinesys.setrecursionlimit(10 ** 7)N = int(input())L = int(input()) * 2X = [0] + [int(input()) * 2 for _ in range(N-1)]# 破綻してないかチェックif any(abs(a - b) >= L for a, b in zip(X[:-1], X[1:])):print(-1)exit()def safe(i, n, g):return n * left[i] < g and g < n * right[i]right = [c + L // 2 for c in X]left = [c - L // 2 for c in X]ans = 0g = 0 # 重心n = 0 # 上にあるパネル数for i in reversed(range(1, N)):n += 1g += X[i]if safe(i, n, g) and safe(i - 1, n, g):continueans += 1print(ans)