結果
問題 | No.2650 [Cherry 6th Tune *] セイジャク |
ユーザー | 👑 emthrm |
提出日時 | 2024-02-23 22:20:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 278 ms / 2,500 ms |
コード長 | 2,001 bytes |
コンパイル時間 | 3,500 ms |
コンパイル使用メモリ | 272,808 KB |
実行使用メモリ | 40,948 KB |
最終ジャッジ日時 | 2024-09-29 07:11:20 |
合計ジャッジ時間 | 11,524 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
#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; }