제출 #1199173

#제출 시각아이디문제언어결과실행 시간메모리
1199173otariusTower (JOI24_tower)C++20
0 / 100
63 ms7852 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> using namespace __gnu_pbds; using namespace std; // #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define ull unsigned long long #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rngl(chrono::steady_clock::now().time_since_epoch().count()); #define int long long // #define int unsigned long long // #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> // #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update> // const ll mod = 1e9 + 7; // const ll mod = 998244353; const ll inf = 1e9; const ll biginf = 1e18; const int maxN = 1e6 + 15; void solve() { int n, q, d, a, b; cin >> n >> q >> d >> a >> b; int l[n + 1], r[n + 1], x[q + 1]; for (int i = 1; i <= n; i++) cin >> l[i] >> r[i]; for (int i = 1; i <= q; i++) cin >> x[i]; int ans[q + 1]; vector<pii> qs; for (int i = 1; i <= q; i++) { ans[i] = -1; qs.pb({x[i], i}); } sort(all(qs)); vector<pii> good; for (int i = 1; i <= n; i++) { if (i == 1) good.pb({0, l[i] - 1}); else good.pb({r[i - 1] + 1, l[i] - 1}); } good.pb({r[n] + 1, biginf}); int j = 0; set<pii> st; for (pii x : good) { int l = x.ff, r = x.sc, mn = r + 1; if (l == 0) mn = 0; else { auto it = st.lower_bound({l, -1}); if (it != st.end()) mn = (*it).ff; if (it != st.begin()) { --it; if ((*it).sc >= l) mn = l; } } while (j + 1 <= q && qs[j + 1].ff < l) j++; while (j + 1 <= q && qs[j + 1].sc <= r) { j++; if (mn <= qs[j].ff) ans[qs[j].sc] = qs[j].ff; } if (mn <= r) st.insert({mn + d, r + d}); } for (int i = 1; i <= q; i++) cout << ans[i] << ' '; } int32_t main() { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...