結果

問題 No.1673 Lamps on a line
ユーザー siman
提出日時 2021-09-12 18:19:15
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 991 ms
コンパイル使用メモリ 142,328 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-24 09:29:57
合計ジャッジ時間 2,881 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

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 + 1, 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