結果

問題 No.2333 Slime Structure
ユーザー FUN_MorikuboFUN_Morikubo
提出日時 2023-05-28 14:52:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,992 bytes
コンパイル時間 5,384 ms
コンパイル使用メモリ 244,320 KB
実行使用メモリ 67,984 KB
最終ジャッジ日時 2024-06-08 06:23:42
合計ジャッジ時間 30,660 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 901 ms
67,724 KB
testcase_13 AC 859 ms
67,848 KB
testcase_14 AC 984 ms
67,804 KB
testcase_15 AC 850 ms
67,800 KB
testcase_16 AC 865 ms
67,980 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#if 1
// clang-format off
#include <bits/stdc++.h>

#include <atcoder/all>

using namespace atcoder;
typedef modint998244353 mint93;
typedef modint1000000007 mint17;
typedef modint mint;

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using lf = long double;
using pll = pair<ll, ll>;
#define vec vector
template <class T> using v = vector<T>;
template <class T> using vv = v<v<T>>;
template <class T> using vvv = v<vv<T>>;
using vl = v<ll>;
using vvl = vv<ll>;
using vvvl = vvv<ll>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, N) for (ll i = 0; i < (ll)(N); i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)(N); i++)
#define rrep(i, N) for (ll i = N - 1; i >= 0; i--)
#define rrep1(i, N) for (ll i = N; i > 0; i--)
#define fore(i, a) for (auto &i : a)
#define fs first
#define sc second
#define eb emplace_back
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define UNIQUE(x) (x).erase(unique((x).begin(), (x).end()), (x).end());
#define YES(x) cout << ((x) ? "YES\n" : "NO\n");
#define Yes(x) cout << ((x) ? "Yes\n" : "No\n");
#define yes(x) cout << ((x) ? "yes\n" : "no\n");
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))
template <class T, class U> void chmin(T &t, const U &u) { if (t > u) t = u; }
template <class T, class U> void chmax(T &t, const U &u) { if (t < u) t = u; }
const int inf = (1 << 29);
const ll infl = (1LL << 60);
const ll mod93 = 998244353;
const ll mod17 = 1000000007;
int popcnt(uint x) { return __builtin_popcount(x); }
int popcnt(ull x) { return __builtin_popcountll(x); }
int bsr(uint x) { return 31 - __builtin_clz(x); }
int bsr(ull x) { return 63 - __builtin_clzll(x); }
int bsf(uint x) { return __builtin_ctz(x); }
int bsf(ull x) { return __builtin_ctzll(x); }

template <class T> istream &operator>>(istream &is, vector<T> &x) { for (auto &y : x) is >> y; return is; }
template <class T> ostream &operator<<(ostream &os, vector<T> &x) {
  for (unsigned int i = 0, size = x.size(); i < size; i++)
    os << x[i] << (i == size - 1 ? "" : " ");
  return os;
}
template <class T, class S> istream &operator>>(istream &is, pair<T, S> &x) { return is >> x.first >> x.second; }
template <class T, class S> ostream &operator<<(ostream &os, pair<T, S> &x) { return os << x.first << " " << x.second; }

ll rand_int(ll l, ll r) {  // [l, r]
  static random_device rd;
  static mt19937 gen(rd());
  return uniform_int_distribution<ll>(l, r)(gen);
}
template <long long MOD> struct binomial {
  long long n;
  std::vector<atcoder::static_modint<MOD>> fact, ifact;
  binomial(long long n) : n(n), fact(n + 1), ifact(n + 1) {
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i > 0; i--)
      ifact[i - 1] = ifact[i] * i;
  }
  atcoder::static_modint<MOD> operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};
// clang-format on
#endif

// #define _GLIBCXX_DEBUG

vl e() { return {-infl, 0, 0, 0, -infl}; }
vl op(vl a, vl b) {
  vl ret = e();
  chmax(ret[0], max(a[0], b[0]));
  chmax(ret[0], a[3] + b[1]);
  ret[1] = max(a[1], a[2] + b[1]);
  ret[2] = a[2] + b[2];
  ret[3] = max(a[3] + b[2], b[3]);
  chmax(ret[4], max(a[4], b[4]));
  ret[0] = *max_element(all(ret));
  return ret;
}

void solve() {
  ll n;
  cin >> n;
  vl a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  vl c(n + 1);
  rep(i, n) c[i + 1] = c[i] + b[i];

  ll q;
  cin >> q;
  vvl query(q, vl(3));
  cin >> query;

  vl d = c;
  rep(i, q) {
    if (query[i][0] == 1) {
      ll x = query[i][1];
      d.eb(x);
      d.eb(x + 1);
    }
    if (query[i][0] == 1) {
      ll l = query[i][1] - 1;
      ll r = query[i][1];
      d.eb(l);
      d.eb(r);
    }
  }

  sort(all(d));
  UNIQUE(d);

  ll m = d.size();
  segtree<vl, op, e> seg(m);
  rep(i, m - 1) {
    ll l = d[i];
    ll r = d[i + 1];
    auto itr = lower_bound(all(c), r);
    ll j = itr - c.begin() - 1;
    ll tmp = a[j] * (r - l);
    seg.set(i, {tmp, tmp, tmp, tmp, a[j]});
  }
  /*
  rep(i, m - 1) {
    vl tmp = seg.get(i);
    cout << i << ": " << tmp << "\n";
  }
  //*/

  rep(i, q) {
    if (query[i][0] == 1) {
      ll x = query[i][1] - 1;
      ll y = query[i][2];
      ll j = lower_bound(all(d), x) - d.begin();
      seg.set(j, {y, y, y, y, y});
    }
    if (query[i][0] == 2) {
      ll l = query[i][1] - 1;
      ll r = query[i][2];
      ll lj = upper_bound(all(d), l) - d.begin() - 1;
      ll rj = lower_bound(all(d), r) - d.begin();
      // cout << l << " " << r << ": " << lj << " " << rj << endl;

      vl ans = seg.prod(lj, rj);
      if(ans[0] == 0) ans[0] = ans[4];
      cout << ans[0] << "\n";
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll t = 1;
  // cin >> t;
  while (t--)
    solve();
}
0