結果

問題 No.1673 Lamps on a line
ユーザー kkkk97368086
提出日時 2021-12-05 08:55:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 338 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 168,412 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 07:03:33
合計ジャッジ時間 3,569 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, Q;
	cin >> N >> Q;

	vector<int> v( N );
	int ans = 0;
	for( int i = 0; i < Q; i++ ) {
		int L, R;
		cin >> L >> R;
		for( int j = L - 1; j < R; j++ ) {
			if( v[j] ) {
				v[j] = 0;
				ans--;
			}
			else {
				v[j] = 1;
				ans++;
			}
		}
		cout << ans << endl;
	}
}
0