結果

問題 No.674 n連勤
ユーザー ei1333333ei1333333
提出日時 2017-05-06 03:57:08
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,051 bytes
コンパイル時間 1,419 ms
コンパイル使用メモリ 151,116 KB
実行使用メモリ 9,404 KB
最終ジャッジ日時 2023-10-12 13:18:18
合計ジャッジ時間 5,410 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,116 KB
testcase_01 AC 3 ms
8,192 KB
testcase_02 AC 4 ms
8,308 KB
testcase_03 AC 3 ms
8,096 KB
testcase_04 AC 3 ms
8,212 KB
testcase_05 AC 4 ms
8,136 KB
testcase_06 AC 3 ms
8,212 KB
testcase_07 AC 3 ms
8,172 KB
testcase_08 AC 4 ms
8,136 KB
testcase_09 AC 3 ms
8,208 KB
testcase_10 AC 3 ms
8,304 KB
testcase_11 AC 54 ms
8,376 KB
testcase_12 AC 45 ms
8,348 KB
testcase_13 AC 18 ms
9,404 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

int main()
{
  int64 D, Q, A[30000], B[30000];
  vector< int64 > nums;
  int64 touch[600000] = {};


  scanf("%lld %lld", &D, &Q);
  for(int i = 0; i < Q; i++) {
    scanf("%lld %lld", &A[i], &B[i]);
    nums.push_back(A[i] - 1);
    nums.push_back(A[i]);
    nums.push_back(B[i]);
    nums.push_back(B[i] + 1);
  }

  sort(begin(nums), end(nums));
  nums.erase(unique(begin(nums), end(nums)), end(nums));

  for(int i = 0; i < Q; i++) {
    A[i] = lower_bound(begin(nums), end(nums), A[i]) - begin(nums);
    B[i] = lower_bound(begin(nums), end(nums), B[i]) - begin(nums);
  }

  int64 ret = 0;
  for(int i = 0; i < Q; i++) {
    for(int64 j = 0; j < nums.size(); j++) {
      if(A[i] <= j && j <= B[i]) touch[j] = true;
    }
    int64 last = -1;
    for(int64 j = 0; j < nums.size(); j++) {
      if(!touch[j]) {
        last = -1;
      } else {
        if(last < 0) last = j;
        ret = max(ret, nums[j] - nums[last] + 1);
      }
    }
    printf("%lld\n", ret);
  }
}
0