結果

問題 No.1673 Lamps on a line
ユーザー simansiman
提出日時 2021-09-12 18:18:33
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 578 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 105,236 KB
実行使用メモリ 4,912 KB
最終ジャッジ日時 2023-09-06 15:04:46
合計ジャッジ時間 3,014 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 87 ms
4,376 KB
testcase_03 AC 87 ms
4,376 KB
testcase_04 AC 148 ms
4,376 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 113 ms
4,744 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 166 ms
4,376 KB
testcase_10 AC 175 ms
4,376 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 199 ms
4,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N, Q;
  cin >> N >> Q;
  int cnt = 0;

  vector<int> lamps(N, 0);
  int l, r;
  for (int i = 0; i < Q; ++i) {
    cin >> l >> r;

    for (int j = l; j <= r; ++j) {
      lamps[j] ^= 1;

      if (lamps[j]) {
        ++cnt;
      } else {
        --cnt;
      }
    }

    cout << cnt << endl;
  }

  return 0;
}
0