結果

問題 No.674 n連勤
ユーザー mitsuomitsuo
提出日時 2018-08-24 12:24:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 983 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 16,816 KB
最終ジャッジ日時 2023-09-02 13:11:12
合計ジャッジ時間 5,897 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,224 KB
testcase_01 AC 15 ms
7,736 KB
testcase_02 AC 16 ms
7,856 KB
testcase_03 AC 16 ms
7,932 KB
testcase_04 AC 15 ms
7,892 KB
testcase_05 AC 16 ms
7,772 KB
testcase_06 AC 14 ms
7,856 KB
testcase_07 AC 15 ms
7,840 KB
testcase_08 AC 15 ms
7,732 KB
testcase_09 AC 16 ms
7,708 KB
testcase_10 AC 15 ms
7,848 KB
testcase_11 AC 31 ms
8,408 KB
testcase_12 AC 538 ms
8,572 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:25: SyntaxWarning: invalid decimal literal
  result.append(max([t[1] - t[0] + 1for t in taskrange]))

ソースコード

diff #

def solve(D, Q, Qs):
    taskrange = []
    result = []
    for q in Qs:
        t = [int(ql) for ql in q.split(" ")]
        merged = False

        while(True):
            merging = False
            for i, task in enumerate(taskrange):
                if t == task: continue
                if task[0] <= t[1] <= task[1] + 1 or task[0] <= t[0] <= task[1]  + 1 or \
                    t[0] <= task[1] <= t[1]  + 1 or t[0] <= task[0] <= t[1]  + 1:
                    taskrange[i] = [min(task[0], t[0]), max(task[1], t[1])]
                    t = task
                    merging = True
                    merged = True
            if not merging:
                break

        if not merged:
            taskrange.append(t)

        result.append(max([t[1] - t[0] + 1for t in taskrange]))

    return result

if __name__ == "__main__":
    D, Q = tuple([int(c) for c in input().split(" ")])
    print("\n".join([str(a) for a in solve(D, Q, [input() for _ in range(0, Q)])]))
0