結果

問題 No.2687 所により大雨
ユーザー SSRSSSRS
提出日時 2024-03-20 21:46:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,420 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 211,296 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-20 21:46:38
合計ジャッジ時間 6,087 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
6,548 KB
testcase_01 AC 89 ms
6,548 KB
testcase_02 AC 89 ms
6,548 KB
testcase_03 AC 88 ms
6,548 KB
testcase_04 AC 88 ms
6,548 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 178 ms
6,548 KB
testcase_11 AC 178 ms
6,548 KB
testcase_12 AC 206 ms
6,548 KB
testcase_13 AC 179 ms
6,548 KB
testcase_14 AC 178 ms
6,548 KB
testcase_15 AC 204 ms
6,548 KB
testcase_16 AC 178 ms
6,548 KB
testcase_17 AC 179 ms
6,548 KB
testcase_18 AC 178 ms
6,548 KB
testcase_19 AC 178 ms
6,548 KB
testcase_20 AC 1 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 4 ms
6,548 KB
testcase_25 AC 4 ms
6,548 KB
testcase_26 AC 3 ms
6,548 KB
testcase_27 AC 3 ms
6,548 KB
testcase_28 AC 3 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<long long, long long>> LR(N + M);
  for (int i = 0; i < N + M; i++){
    cin >> LR[i].first >> LR[i].second;
  }
  int K;
  cin >> K;
  vector<long long> P(K);
  for (int i = 0; i < K; i++){
    cin >> P[i];
  }
  sort(LR.begin(), LR.begin() + N);
  sort(LR.begin() + N, LR.end());
  bool ok = false;
  for (int i = 0; i < N - 1; i++){
    if (LR[i].second >= LR[i + 1].first){
      ok = true;
    }
  }
  for (int i = N; i < N + M - 1; i++){
    if (LR[i].second >= LR[i + 1].first){
      ok = false;
    }
  }
  if (ok){
    for (int i = 0; i < K; i++){
      cout << 1;
      if (i < K - 1){
        cout << ' ';
      }
    }
    cout << endl;
  } else {
    vector<long long> L(N + M), R(N + M);
    for (int i = 0; i < N + M; i++){
      L[i] = LR[i].first;
      R[i] = LR[i].second;
    }
    for (int i = 0; i < K; i++){
      int E = 0;
      for (int j = N; j < N + M; j++){
        long long l = 2 * P[i] - R[j];
        long long r = 2 * P[i] - L[j];
        int p = lower_bound(L.begin(), L.begin() + N, l) - L.begin();
        if (p < N){
          if (L[p] <= r){
            E = 1;
          }
        }
        if (p > 0){
          if (l <= R[p - 1]){
            E = 1;
          }
        }
      }
      cout << E;
      if (i < K - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
}
0