結果

問題 No.343 手抜き工事のプロ
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-02-13 00:00:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 365 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 13,944 KB
最終ジャッジ日時 2023-10-22 03:44:10
合計ジャッジ時間 3,207 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,168 KB
testcase_01 AC 32 ms
10,168 KB
testcase_02 AC 31 ms
10,168 KB
testcase_03 AC 30 ms
10,168 KB
testcase_04 AC 29 ms
10,168 KB
testcase_05 AC 29 ms
10,168 KB
testcase_06 AC 29 ms
10,168 KB
testcase_07 AC 29 ms
10,168 KB
testcase_08 AC 29 ms
10,168 KB
testcase_09 AC 29 ms
10,168 KB
testcase_10 AC 29 ms
10,168 KB
testcase_11 AC 29 ms
10,168 KB
testcase_12 AC 29 ms
10,168 KB
testcase_13 AC 63 ms
10,420 KB
testcase_14 AC 32 ms
10,172 KB
testcase_15 AC 30 ms
10,172 KB
testcase_16 AC 28 ms
10,168 KB
testcase_17 AC 28 ms
10,168 KB
testcase_18 AC 29 ms
10,168 KB
testcase_19 AC 29 ms
10,168 KB
testcase_20 AC 60 ms
10,520 KB
testcase_21 AC 120 ms
11,304 KB
testcase_22 AC 164 ms
10,512 KB
testcase_23 AC 203 ms
12,360 KB
testcase_24 AC 311 ms
13,152 KB
testcase_25 AC 360 ms
13,944 KB
testcase_26 AC 365 ms
13,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

N = int(input())
L = int(input())

if N == 1:
    print(0)
    exit()

X = [None] * N
X[0] = 0
for i in range(1, N):
    X[i] = int(input())

numer = 0
denom = 0
ans = N-1
for i in range(N-2, 0-1, -1):
    if abs(X[i+1] - X[i]) >= L:
        print(-1)
        exit()

    numer += X[i+1]
    denom += 1
    if X[i] < numer/denom + L/2 < X[i] + L and X[i+1] < numer/denom + L/2 < X[i+1] + L:
        ans -= 1

print(ans)
0