結果

問題 No.1673 Lamps on a line
ユーザー ktr216ktr216
提出日時 2021-09-10 21:29:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 168,016 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 15:59:46
合計ジャッジ時間 3,570 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 81 ms
4,380 KB
testcase_03 AC 79 ms
4,376 KB
testcase_04 AC 137 ms
4,380 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 116 ms
4,380 KB
testcase_07 AC 104 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 154 ms
4,380 KB
testcase_10 AC 154 ms
4,376 KB
testcase_11 AC 15 ms
4,376 KB
testcase_12 AC 187 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

int main() {
    int N, Q, ans = 0;
    cin >> N >> Q;
    vector<int> L(Q), R(Q);
    rep(i, 0, Q) cin >> L[i] >> R[i];
    vector<bool> A(N + 1, 0);
    rep(i, 0, Q) {
        rep(j, L[i], R[i] + 1) {
            A[j] = 1 - A[j];
            if (A[j]) ans++;
            else ans--;
        }
        cout << ans << endl;
    }
}
0