結果

問題 No.1673 Lamps on a line
ユーザー SSRS
提出日時 2021-09-10 21:21:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 167,796 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-11 22:10:36
合計ジャッジ時間 3,747 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, Q;
  cin >> N >> Q;
  vector<int> A(N, 0);
  int S = 0;
  for (int i = 0; i < Q; i++){
    int L, R;
    cin >> L >> R;
    L--;
    for (int j = L; j < R; j++){
      S -= A[j];
      A[j] = 1 - A[j];
      S += A[j];
    }
    cout << S << endl;
  }
}
0