結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー KudeKude
提出日時 2022-06-17 22:16:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 351 ms / 3,000 ms
コード長 2,062 bytes
コンパイル時間 2,533 ms
コンパイル使用メモリ 229,988 KB
最終ジャッジ日時 2025-01-29 22:09:51
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic pop
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
constexpr long long INF = 1002003004005006007;
ll op(ll x, ll y) { return min(x, y); }
ll e() { return INF; }
ll composition(ll f, ll g) { return f + g; }
ll id() { return 0; }
ll mapping(ll f, ll x) { return f + x; }
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k, q;
cin >> n >> k >> q;
struct Q { int l, r, c, h; };
vector<Q> builds(k);
for(auto& [l, r, c, h]: builds) {
cin >> l >> r >> c >> h;
l--;
}
// qid, i, x
vector<tuple<int, int, ll>> queries(q);
rep(tt, q) {
auto& [qid, i, x] = queries[tt];
qid = tt;
cin >> i >> x;
i--, x--;
}
sort(all(queries), [](const tuple<int, int, ll>& x, const tuple<int, int, ll>& y) {
return get<1>(x) < get<1>(y);
});
VI idx(n + 1);
{
int now = 0;
rep(i, n) {
while(now < q && get<1>(queries[now]) < i) now++;
idx[i] = now;
}
idx[n] = q;
}
VL init_vec(q);
rep(i, q) init_vec[i] = get<2>(queries[i]);
lazy_segtree<ll, op, e, ll, mapping, composition, id> seg(init_vec);
VI ans(q, -1);
for(auto [l, r, c, h]: builds) {
seg.apply(idx[l], idx[r], -h);
while(true) {
int i = seg.max_right(0, [](ll x) { return x >= 0; });
if (i == q) break;
ans[get<0>(queries[i])] = c;
seg.set(i, INF);
}
}
rep(i, q) cout << ans[i] << '\n';
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0