結果

問題 No.1673 Lamps on a line
ユーザー 杨娵隅杨娵隅
提出日時 2021-09-10 23:02:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 164,220 KB
実行使用メモリ 4,920 KB
最終ジャッジ日時 2023-09-02 20:53:40
合計ジャッジ時間 3,070 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 13 ms
4,368 KB
testcase_03 AC 13 ms
4,368 KB
testcase_04 AC 22 ms
4,368 KB
testcase_05 AC 3 ms
4,372 KB
testcase_06 AC 20 ms
4,368 KB
testcase_07 AC 24 ms
4,920 KB
testcase_08 AC 3 ms
4,388 KB
testcase_09 AC 30 ms
4,372 KB
testcase_10 AC 33 ms
4,496 KB
testcase_11 AC 5 ms
4,532 KB
testcase_12 AC 32 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
int a[maxn];
int main()
{
  int N, Q; cin >> N >> Q;
  int cnt = 0;
  while (Q --)
  {
    int l, r; scanf("%d %d", &l, &r);
    for (int i = l; i <= r; i ++)
    {
      if (a[i]) 
      {
        a[i] = 0;
        cnt --;
      }
      else 
      {
        a[i] = 1;
        cnt ++;
      }
    }
    cout << cnt << "\n";
  }
  
  return 0;
}
0