結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー KudeKude
提出日時 2022-06-17 22:16:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 390 ms / 3,000 ms
コード長 2,062 bytes
コンパイル時間 3,007 ms
コンパイル使用メモリ 232,656 KB
実行使用メモリ 18,872 KB
最終ジャッジ日時 2024-04-17 14:19:32
合計ジャッジ時間 12,483 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 98 ms
15,104 KB
testcase_04 AC 143 ms
15,744 KB
testcase_05 AC 113 ms
6,144 KB
testcase_06 AC 177 ms
11,648 KB
testcase_07 AC 214 ms
11,624 KB
testcase_08 AC 144 ms
15,616 KB
testcase_09 AC 175 ms
15,472 KB
testcase_10 AC 184 ms
11,264 KB
testcase_11 AC 106 ms
6,528 KB
testcase_12 AC 199 ms
16,000 KB
testcase_13 AC 118 ms
14,424 KB
testcase_14 AC 135 ms
6,528 KB
testcase_15 AC 123 ms
14,004 KB
testcase_16 AC 132 ms
6,912 KB
testcase_17 AC 299 ms
17,032 KB
testcase_18 AC 252 ms
16,128 KB
testcase_19 AC 286 ms
13,524 KB
testcase_20 AC 42 ms
9,088 KB
testcase_21 AC 64 ms
6,272 KB
testcase_22 AC 145 ms
14,900 KB
testcase_23 AC 62 ms
9,088 KB
testcase_24 AC 115 ms
7,680 KB
testcase_25 AC 284 ms
17,236 KB
testcase_26 AC 287 ms
17,152 KB
testcase_27 AC 55 ms
5,376 KB
testcase_28 AC 89 ms
15,744 KB
testcase_29 AC 352 ms
18,636 KB
testcase_30 AC 310 ms
18,816 KB
testcase_31 AC 140 ms
15,744 KB
testcase_32 AC 350 ms
18,872 KB
testcase_33 AC 390 ms
18,640 KB
testcase_34 AC 307 ms
18,808 KB
権限があれば一括ダウンロードができます

ソースコード

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';
}
0