結果

問題 No.1673 Lamps on a line
ユーザー mamimume____mo
提出日時 2021-09-10 22:02:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 1,666 ms
コンパイル使用メモリ 168,008 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-12 00:08:08
合計ジャッジ時間 3,706 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000100;
const ll INFL = 2e18;
template <class T>bool chmin(T &a, T b){ if (a > b) { a = b; return true;} else return false;}
template <class T>bool chmax(T &a, T b){ if (a < b) { a = b; return true;} else return false;}

int main() {
    int N;
    cin >> N;
    int Q;
    cin >> Q;

    vector<int> Lamp(N,0);
    int now = 0;
    for (int i = 0;i < Q;i++) {
        int L,R;
        cin >> L >> R;
        L--,R--;
        for (int j = L;j <= R;j++) {
            if (Lamp[j]) {
                now--;
                Lamp[j] = 0;
            }
            else {
                now++;
                Lamp[j] = 1;
            }
        }

        cout << now << endl;
    }
}
0