結果

問題 No.1673 Lamps on a line
ユーザー You_sakuYou_saku
提出日時 2021-09-16 01:16:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 1,933 ms
コンパイル使用メモリ 81,344 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 12:35:06
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 89 ms
4,380 KB
testcase_03 AC 89 ms
4,384 KB
testcase_04 AC 153 ms
4,380 KB
testcase_05 AC 9 ms
4,384 KB
testcase_06 AC 132 ms
4,380 KB
testcase_07 AC 115 ms
4,384 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 173 ms
4,380 KB
testcase_10 AC 175 ms
4,384 KB
testcase_11 AC 16 ms
4,384 KB
testcase_12 AC 200 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include <ios>
#include <iomanip> 
#include<algorithm>

using namespace std;

int main(){
    int n,q;
    cin >> n >> q;
    vector<bool>lamp(n,0);
    int count = 0;
    for(int i=0; i<q; i++){
        int start,end;
        cin >> start >> end;
        for(int j = start-1; j < end; j++){
            if(lamp[j]){
                lamp[j] = false;
                count--;
            }else{
                lamp[j] = true;
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}
0