結果

問題 No.1673 Lamps on a line
ユーザー Akkapelli HarshithAkkapelli Harshith
提出日時 2021-09-10 23:10:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 165,768 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 21:17:34
合計ジャッジ時間 3,790 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 85 ms
4,372 KB
testcase_03 AC 84 ms
4,368 KB
testcase_04 AC 148 ms
4,372 KB
testcase_05 AC 9 ms
4,368 KB
testcase_06 AC 125 ms
4,368 KB
testcase_07 AC 110 ms
4,372 KB
testcase_08 AC 3 ms
4,372 KB
testcase_09 AC 165 ms
4,368 KB
testcase_10 AC 172 ms
4,368 KB
testcase_11 AC 16 ms
4,372 KB
testcase_12 AC 198 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main(){
    int n,q;
    cin >> n >> q;
    vector<bool> v(n, false);
    int ans = 0;
    while(q--){
        int l,r;
        cin >> l >> r;
        l--;
        r--;
        int before = 0, after = 0; 
        for(int i = l;i <= r;i++){
        	if(v[i]){
        		before++;
        	}
            v[i] = not(v[i]);
            if(v[i]){
            	after++;
            }
        }
        ans -= before;
        ans += after;
        cout << ans << "\n";
    }
    
    return 0;
}
0