結果

問題 No.343 手抜き工事のプロ
ユーザー HachimoriHachimori
提出日時 2016-02-13 00:32:00
言語 Python2
(2.7.18)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 7,112 KB
実行使用メモリ 13,276 KB
最終ジャッジ日時 2023-10-22 03:47:16
合計ジャッジ時間 2,564 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,408 KB
testcase_01 AC 11 ms
6,408 KB
testcase_02 AC 11 ms
6,408 KB
testcase_03 AC 11 ms
6,408 KB
testcase_04 AC 11 ms
6,408 KB
testcase_05 AC 11 ms
6,408 KB
testcase_06 AC 11 ms
6,408 KB
testcase_07 AC 11 ms
6,408 KB
testcase_08 AC 11 ms
6,408 KB
testcase_09 AC 11 ms
6,408 KB
testcase_10 AC 11 ms
6,408 KB
testcase_11 AC 11 ms
6,408 KB
testcase_12 AC 11 ms
6,408 KB
testcase_13 AC 33 ms
7,052 KB
testcase_14 AC 13 ms
6,420 KB
testcase_15 AC 12 ms
6,424 KB
testcase_16 AC 11 ms
6,408 KB
testcase_17 AC 11 ms
6,408 KB
testcase_18 AC 11 ms
6,408 KB
testcase_19 AC 11 ms
6,408 KB
testcase_20 AC 32 ms
7,176 KB
testcase_21 AC 75 ms
8,476 KB
testcase_22 AC 103 ms
8,468 KB
testcase_23 AC 133 ms
10,660 KB
testcase_24 AC 192 ms
12,004 KB
testcase_25 AC 229 ms
13,276 KB
testcase_26 AC 228 ms
13,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8

def read():
    N = int(raw_input())
    L = int(raw_input())
    xList = []
    xList.append(0)
    for i in range(N - 1):
        xList.append(int(raw_input()))
    return L, xList


def work((L, xList)):
    xList = xList[::-1]

    ans = 0
    total = 0
    
    for i in range(len(xList)):
        if i > 0:
            # not (xList[i    ] - L / 2 < total / i < xList[i    ] + L / 2) or
            # not (xList[i + 1] - L / 2 < total / i < xList[i + 1] + L / 2)
            if not (i * (2 * xList[i    ] - L)  < 2 * total < i * (2 * xList[i    ] + L)) or \
               not (i * (2 * xList[i - 1] - L)  < 2 * total < i * (2 * xList[i - 1] + L)):
                ans += 1
            
            if abs(xList[i - 1] - xList[i]) >= L:
                print -1
                return
        
        total += xList[i]

    print ans

    
if __name__ == "__main__":
    work(read())
0