結果

問題 No.1673 Lamps on a line
ユーザー You_saku
提出日時 2021-09-16 01:16:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 02:59:07
合計ジャッジ時間 2,581 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

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