結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー 👑 emthrmemthrm
提出日時 2024-02-23 22:20:48
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 291 ms / 2,500 ms
コード長 2,001 bytes
コンパイル時間 3,519 ms
コンパイル使用メモリ 273,232 KB
実行使用メモリ 41,252 KB
最終ジャッジ日時 2024-02-23 22:21:11
合計ジャッジ時間 11,702 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 52 ms
11,904 KB
testcase_03 AC 33 ms
8,448 KB
testcase_04 AC 200 ms
29,856 KB
testcase_05 AC 141 ms
23,412 KB
testcase_06 AC 70 ms
13,440 KB
testcase_07 AC 164 ms
25,408 KB
testcase_08 AC 47 ms
10,624 KB
testcase_09 AC 291 ms
38,908 KB
testcase_10 AC 271 ms
38,948 KB
testcase_11 AC 270 ms
38,948 KB
testcase_12 AC 270 ms
38,948 KB
testcase_13 AC 270 ms
38,948 KB
testcase_14 AC 271 ms
38,948 KB
testcase_15 AC 271 ms
38,928 KB
testcase_16 AC 209 ms
36,516 KB
testcase_17 AC 207 ms
36,624 KB
testcase_18 AC 210 ms
36,516 KB
testcase_19 AC 209 ms
36,516 KB
testcase_20 AC 208 ms
36,516 KB
testcase_21 AC 207 ms
36,516 KB
testcase_22 AC 206 ms
36,516 KB
testcase_23 AC 153 ms
36,644 KB
testcase_24 AC 160 ms
36,644 KB
testcase_25 AC 154 ms
36,644 KB
testcase_26 AC 155 ms
36,644 KB
testcase_27 AC 154 ms
36,644 KB
testcase_28 AC 154 ms
36,644 KB
testcase_29 AC 155 ms
36,644 KB
testcase_30 AC 183 ms
36,604 KB
testcase_31 AC 182 ms
41,252 KB
testcase_32 AC 85 ms
16,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, a; cin >> n >> a;
  vector<int> x(n);
  for (int& x_i : x) cin >> x_i;
  int t; cin >> t;
  vector<int> l(t), r(t); REP(i, t) cin >> l[i] >> r[i];
  vector<int> pts;
  pts.reserve(n + 2 * t);
  ranges::copy(x, back_inserter(pts));
  ranges::copy(l, back_inserter(pts));
  ranges::copy(r, back_inserter(pts));
  ranges::sort(pts);
  pts.erase(unique(pts.begin(), pts.end()), pts.end());
  const int m = pts.size();
  REP(i, n) x[i] = distance(pts.begin(), ranges::lower_bound(pts, x[i]));
  REP(i, t) l[i] = distance(pts.begin(), ranges::lower_bound(pts, l[i]));
  REP(i, t) r[i] = distance(pts.begin(), ranges::lower_bound(pts, r[i]));
  vector<vector<int>> ins(m), era(m), queries(m);
  REP(i, t) ins[l[i]].emplace_back(i);
  REP(i, t) era[r[i]].emplace_back(i);
  REP(i, n) queries[x[i]].emplace_back(i);
  vector<int> ans(n, -1);
  set<int> sounds;
  REP(i, m) {
    for (const int id : ins[i]) sounds.emplace(id);
    if (!sounds.empty()) {
      for (const int id : queries[i]) ans[id] = *sounds.rbegin() + 1;
    }
    for (const int id : era[i]) sounds.erase(id);
  }
  for (const int ans_i : ans) cout << ans_i << '\n';
  return 0;
}
0