結果

問題 No.1673 Lamps on a line
ユーザー shishimaiotoshishishimaiotoshi
提出日時 2021-09-11 00:53:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 165,588 KB
実行使用メモリ 5,016 KB
最終ジャッジ日時 2023-09-03 15:35:08
合計ジャッジ時間 3,945 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 89 ms
4,380 KB
testcase_03 AC 87 ms
4,380 KB
testcase_04 AC 152 ms
4,380 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 128 ms
4,384 KB
testcase_07 AC 115 ms
4,884 KB
testcase_08 AC 4 ms
4,384 KB
testcase_09 AC 169 ms
4,380 KB
testcase_10 AC 179 ms
4,380 KB
testcase_11 AC 17 ms
4,384 KB
testcase_12 AC 202 ms
5,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n, o) for(int i = o;i < (n);i++)
#define ou(x) cout << x << endl
#define ll long long
#define re return 0
signed main(){
    int n, q;
    string s;
    cin >> n >> q;
    std::vector<int> v(n, 0);
    int l;
    int r;
    int ans = 0;
    rep(i, q, 0){
        cin >> l >> r;
        rep(j, r, l - 1){
            if(v[j] == 1){
                v[j] = 0;
                ans--;
                continue;
            }
            v[j] = 1;
            if(v[j] == 1){
                ans++;
            }
        }
        ou(ans);
    }
    re;
}
0