結果

問題 No.1673 Lamps on a line
ユーザー みここみここ
提出日時 2021-09-10 21:35:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 64,900 KB
実行使用メモリ 5,572 KB
最終ジャッジ日時 2023-09-02 16:10:06
合計ジャッジ時間 2,674 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,316 KB
testcase_01 AC 3 ms
5,380 KB
testcase_02 AC 84 ms
5,572 KB
testcase_03 AC 78 ms
5,460 KB
testcase_04 AC 147 ms
5,332 KB
testcase_05 AC 10 ms
5,308 KB
testcase_06 AC 121 ms
5,312 KB
testcase_07 AC 110 ms
5,304 KB
testcase_08 AC 4 ms
5,328 KB
testcase_09 AC 155 ms
5,300 KB
testcase_10 AC 157 ms
5,288 KB
testcase_11 AC 17 ms
5,460 KB
testcase_12 AC 184 ms
5,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n, q;
    cin >> n >> q;
    int d[500005]{0};
    int ans = 0;
    while(q--){
        int l, r;
        cin >> l >> r;
        l--;
        for(int i = l; i < r; i++){
            if(d[i]) ans--;
            else ans++;
            d[i] ^= 1;
        }
        cout << ans << endl;
    }
}
0