結果

問題 No.1673 Lamps on a line
ユーザー hourenhouren
提出日時 2021-09-10 21:28:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 1,573 ms
コンパイル使用メモリ 165,528 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 15:57:20
合計ジャッジ時間 3,676 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 88 ms
4,380 KB
testcase_03 AC 86 ms
4,380 KB
testcase_04 AC 152 ms
4,376 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 126 ms
4,380 KB
testcase_07 AC 111 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 169 ms
4,380 KB
testcase_10 AC 176 ms
4,376 KB
testcase_11 AC 16 ms
4,380 KB
testcase_12 AC 202 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,q;
    cin >> n >> q;
    vector<bool> x(n,false);
    int ans = 0;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        l--; r--;
        for(int j=l;j<=r;j++){
            ans -= x[j];
            x[j] = x[j] - 1;
            ans += x[j];
        }
        cout << ans << endl;
    }
    return 0;
}
0