結果

問題 No.1673 Lamps on a line
ユーザー umezoumezo
提出日時 2021-09-10 22:28:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 501 bytes
コンパイル時間 1,960 ms
コンパイル使用メモリ 197,904 KB
実行使用メモリ 4,852 KB
最終ジャッジ日時 2023-09-02 18:48:56
合計ジャッジ時間 3,902 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 77 ms
4,368 KB
testcase_03 AC 75 ms
4,368 KB
testcase_04 AC 131 ms
4,372 KB
testcase_05 AC 8 ms
4,372 KB
testcase_06 AC 113 ms
4,368 KB
testcase_07 AC 94 ms
4,852 KB
testcase_08 AC 4 ms
4,404 KB
testcase_09 AC 136 ms
4,372 KB
testcase_10 AC 142 ms
4,368 KB
testcase_11 AC 15 ms
4,432 KB
testcase_12 AC 152 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int A[500500];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,q;
  cin>>n>>q;
  int cnt=0;
  rep(i,q){
    int l,r;
    cin>>l>>r;
    for(int j=l;j<=r;j++){
      if(A[j]==0){
        A[j]=1;
        cnt++;
      }
      else{
        A[j]=0;
        cnt--;
      }
    }
    cout<<cnt<<endl;
  }
  
  
  
  return 0;
}
0