結果

問題 No.1673 Lamps on a line
ユーザー nawawannawawan
提出日時 2021-09-10 21:55:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 198,884 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-09-02 17:07:33
合計ジャッジ時間 4,289 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 81 ms
4,372 KB
testcase_03 AC 85 ms
4,372 KB
testcase_04 AC 140 ms
4,372 KB
testcase_05 AC 8 ms
4,372 KB
testcase_06 AC 113 ms
4,368 KB
testcase_07 AC 107 ms
4,688 KB
testcase_08 AC 4 ms
4,368 KB
testcase_09 AC 155 ms
4,368 KB
testcase_10 AC 154 ms
4,372 KB
testcase_11 AC 15 ms
4,372 KB
testcase_12 AC 182 ms
4,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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