結果

問題 No.1673 Lamps on a line
ユーザー AzumabashiAzumabashi
提出日時 2022-01-26 18:13:03
言語 Nim
(2.0.2)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 351 bytes
コンパイル時間 4,613 ms
コンパイル使用メモリ 68,308 KB
実行使用メモリ 6,952 KB
最終ジャッジ日時 2023-08-24 23:58:35
合計ジャッジ時間 7,761 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 99 ms
4,380 KB
testcase_03 AC 98 ms
4,384 KB
testcase_04 AC 173 ms
4,380 KB
testcase_05 AC 11 ms
4,384 KB
testcase_06 AC 147 ms
4,380 KB
testcase_07 AC 122 ms
6,056 KB
testcase_08 AC 4 ms
5,148 KB
testcase_09 AC 181 ms
4,380 KB
testcase_10 AC 189 ms
4,856 KB
testcase_11 AC 19 ms
5,060 KB
testcase_12 AC 204 ms
6,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils, strutils

var n, q, r, l: int
(n, q) = map(readLine(stdin).split(), parseInt)
var ans: int = 0
var a = newSeq[int](n)
for _ in 0..<q:
  (l, r) = map(readLine(stdin).split(), parseInt)
  l = l - 1
  r = r - 1
  for i in l..r:
    if a[i] == 1:
      a[i] = 0
      ans = ans - 1
    else:
      a[i] = 1
      ans = ans + 1
  echo ans
0