結果
| 問題 | 
                            No.1673 Lamps on a line
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-09-10 21:48:43 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 394 bytes | 
| コンパイル時間 | 2,036 ms | 
| コンパイル使用メモリ | 193,064 KB | 
| 最終ジャッジ日時 | 2025-01-24 10:13:08 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 7 TLE * 4 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |     int l, r; scanf("%d %d", &l, &r);
      |               ~~~~~^~~~~~~~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
int a[maxn];
int main()
{
  int N, Q; cin >> N >> Q;
  
  while (Q --)
  {
    int l, r; scanf("%d %d", &l, &r);
    
    for (int i = l; i <= r; i ++)
    {
      if (a[i]) a[i] = 0;
      else a[i] = 1;
    }int cnt = 0;
    for (int i = 1; i <= N; i ++) if (a[i]) cnt ++; 
    cout << cnt << "\n";
  }
  
  return 0;
}