結果
問題 | No.343 手抜き工事のプロ |
ユーザー |
![]() |
提出日時 | 2020-03-02 17:31:06 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 15,488 KB |
最終ジャッジ日時 | 2024-10-13 21:15:04 |
合計ジャッジ時間 | 2,434 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return sys.stdin.readline()[:-1] def main(): n=II() l=II() xx=[0]+[II() for _ in range(n-1)] xx.reverse() s=0 ans=n-1 for i in range(n): if i: if abs(pre-xx[i])>=l: print(-1) exit() if (2*xx[i]-l)*i<2*s<(2*xx[i]+l)*i and (2*xx[i-1]-l)*i<2*s<(2*xx[i-1]+l)*i:ans-=1 pre=xx[i] s+=xx[i] print(ans) main()