結果

問題 No.1673 Lamps on a line
ユーザー ぷらぷら
提出日時 2021-09-10 21:22:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 200,084 KB
実行使用メモリ 5,024 KB
最終ジャッジ日時 2023-09-02 15:41:25
合計ジャッジ時間 3,995 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 83 ms
4,380 KB
testcase_03 AC 83 ms
4,376 KB
testcase_04 AC 140 ms
4,376 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 118 ms
4,376 KB
testcase_07 AC 107 ms
4,712 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 159 ms
4,380 KB
testcase_10 AC 160 ms
4,376 KB
testcase_11 AC 16 ms
4,380 KB
testcase_12 AC 183 ms
5,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,Q;
    cin >> N >> Q;
    vector<int>sum(N+1);
    int ans = 0;
    for(int i = 0; i < Q; i++) {
        int l,r;
        cin >> l >> r;
        l--;
        r--;
        for(int j = l; j <= r; j++) {
            sum[j] ^= 1;
            if(sum[j] == 0) {
                ans--;
            }
            else {
                ans++;
            }
        }
        cout << ans << endl;
    }
}
0