結果

問題 No.1673 Lamps on a line
ユーザー 河野竜也河野竜也
提出日時 2021-09-12 17:32:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 787 ms / 2,000 ms
コード長 212 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 10,460 KB
実行使用メモリ 11,924 KB
最終ジャッジ日時 2023-09-06 14:10:10
合計ジャッジ時間 5,600 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,792 KB
testcase_01 AC 14 ms
7,760 KB
testcase_02 AC 290 ms
7,764 KB
testcase_03 AC 296 ms
7,764 KB
testcase_04 AC 516 ms
7,940 KB
testcase_05 AC 37 ms
7,944 KB
testcase_06 AC 432 ms
7,840 KB
testcase_07 AC 412 ms
10,756 KB
testcase_08 AC 20 ms
10,144 KB
testcase_09 AC 567 ms
8,560 KB
testcase_10 AC 606 ms
9,904 KB
testcase_11 AC 66 ms
10,060 KB
testcase_12 AC 787 ms
11,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,q=map(int,input().split())
ans=0
d=[0]*(n+1)
for i in range(q):
  l,r=map(int,input().split())
  for j in range(l,r+1):
    if d[j]==0:
      d[j]=1
      ans+=1
    else:
      d[j]=0
      ans-=1
  print(ans)
0