結果

問題 No.674 n連勤
ユーザー Mr.FukuMr.Fuku
提出日時 2018-08-13 18:54:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 797 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 21,912 KB
最終ジャッジ日時 2023-10-24 16:42:53
合計ジャッジ時間 6,343 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 OLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

D,Q = map(int,input().split())
union = []
maxd = 0

for i in range(Q):
    s,t = map(int,input().split())
    index = len(union)
    for j in range(len(union)):
        if union[j][0]>s:
            index = j
            break
    t_bond,b_bond = False,False
    if index>0 and union[index-1][1]+1>=s:t_bond=True
    if index<len(union) and union[index][0]-1<=t:b_bond=True
    if t_bond and b_bond:
        union[index-1][1]=max(t,union[index][1])
        union.pop(index)
        index-=1
    elif t_bond:
        union[index-1][1]=max(t,union[index-1][1])
        index-=1
    elif b_bond:
        union[index][0]=s
        union[index][1]=max(t,union[index][1])
    else:
        union.insert(index,[s,t])
    maxd = max(maxd,union[index][1]-union[index][0]+1)
    print(maxd)
    print(union)
0