結果

問題 No.1673 Lamps on a line
ユーザー mkawa2mkawa2
提出日時 2021-09-10 21:25:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 475 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 12,432 KB
最終ジャッジ日時 2023-09-02 15:49:54
合計ジャッジ時間 3,580 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,884 KB
testcase_01 AC 16 ms
7,820 KB
testcase_02 AC 130 ms
8,708 KB
testcase_03 AC 126 ms
8,584 KB
testcase_04 AC 214 ms
8,564 KB
testcase_05 AC 27 ms
8,572 KB
testcase_06 AC 194 ms
8,652 KB
testcase_07 AC 229 ms
11,280 KB
testcase_08 AC 24 ms
10,432 KB
testcase_09 AC 328 ms
8,872 KB
testcase_10 AC 347 ms
10,308 KB
testcase_11 AC 48 ms
10,464 KB
testcase_12 AC 475 ms
12,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**20
md = 998244353
# md = 10**9+7

n,q=LI()
ans=0
aa=[0]*n
for _ in range(q):
    l,r=LI()
    for i in range(l-1,r):
        if aa[i]:
            aa[i]=0
            ans-=1
        else:
            aa[i]=1
            ans+=1
    print(ans)
0