結果
問題 | No.2333 Slime Structure |
ユーザー | hikikomori |
提出日時 | 2023-05-09 02:08:51 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 426 ms / 3,000 ms |
コード長 | 3,021 bytes |
コンパイル時間 | 5,298 ms |
コンパイル使用メモリ | 321,112 KB |
実行使用メモリ | 108,588 KB |
最終ジャッジ日時 | 2024-05-04 06:59:50 |
合計ジャッジ時間 | 21,042 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
7,168 KB |
testcase_01 | AC | 4 ms
7,296 KB |
testcase_02 | AC | 176 ms
54,472 KB |
testcase_03 | AC | 243 ms
96,608 KB |
testcase_04 | AC | 272 ms
94,548 KB |
testcase_05 | AC | 194 ms
57,608 KB |
testcase_06 | AC | 281 ms
97,516 KB |
testcase_07 | AC | 325 ms
102,988 KB |
testcase_08 | AC | 323 ms
103,688 KB |
testcase_09 | AC | 324 ms
102,956 KB |
testcase_10 | AC | 333 ms
103,616 KB |
testcase_11 | AC | 320 ms
102,892 KB |
testcase_12 | AC | 343 ms
103,380 KB |
testcase_13 | AC | 323 ms
103,320 KB |
testcase_14 | AC | 327 ms
104,552 KB |
testcase_15 | AC | 319 ms
102,856 KB |
testcase_16 | AC | 318 ms
103,220 KB |
testcase_17 | AC | 326 ms
103,724 KB |
testcase_18 | AC | 347 ms
103,284 KB |
testcase_19 | AC | 325 ms
103,172 KB |
testcase_20 | AC | 321 ms
103,732 KB |
testcase_21 | AC | 335 ms
103,888 KB |
testcase_22 | AC | 410 ms
108,404 KB |
testcase_23 | AC | 408 ms
108,556 KB |
testcase_24 | AC | 414 ms
108,128 KB |
testcase_25 | AC | 406 ms
108,072 KB |
testcase_26 | AC | 414 ms
108,084 KB |
testcase_27 | AC | 408 ms
108,220 KB |
testcase_28 | AC | 412 ms
108,096 KB |
testcase_29 | AC | 417 ms
108,232 KB |
testcase_30 | AC | 426 ms
108,244 KB |
testcase_31 | AC | 410 ms
108,588 KB |
testcase_32 | AC | 340 ms
105,820 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using ld = long double; using P = pair<int, int>; using Graph = vector<vector<ll>>; using vi = vector<int>; using vl = vector<long>; using vll = vector<long long>; using vvi = vector<vi>; using vvl = vector<vl>; using vvll = vector<vll>; using vs = vector<string>; using vc = vector<char>; using vvc = vector<vc>; using pll = pair<long long, long long>; using vpll = vector<pll>; using mint = modint1000000007; const long double EPS = 1e-18; const long long INF = 1e15; const long double PI = acos(-1.0L); #define reps(i, a, n) for (ll i = (a); i < (ll)(n); i++) #define rep(i, n) for (ll i = (0); i < (ll)(n); i++) #define rrep(i, n) for (ll i = (1); i < (ll)(n + 1); i++) #define repd(i, n) for (ll i = n - 1; i >= 0; i--) #define rrepd(i, n) for (ll i = n; i >= 1; i--) #define ALL(n) begin(n), end(n) #define IN(a, x, b) (a <= x && x < b) #define INIT \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); template <class T> inline T CHMAX(T& a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; } struct S { ll left_max; ll right_max; ll kukan_max; ll sum; }; S op(S a, S b) { return S{max(a.left_max, a.sum + b.left_max), max(b.right_max, b.sum + a.right_max), max(max(a.kukan_max, b.kukan_max), a.right_max + b.left_max), a.sum + b.sum}; } S e() { return S{-INF, -INF, -INF, 0ll}; } int main() { INIT; ll N; cin >> N; vll A(1e5 + 100), B(1e5 + 100); rrep(i, N) { cin >> A[i] >> B[i]; } ll Q; cin >> Q; vll q(1e5 + 100), a(1e5 + 100), b(1e5 + 100); vll num; num.push_back(0ll); rrep(i, N) { num.push_back(num[i - 1] + B[i]); } vll numnum = num; rrep(i, N) { num.push_back(numnum[i] - 1); num.push_back(numnum[i] + 1); } rrep(i, Q) { cin >> q[i] >> a[i] >> b[i]; num.push_back(a[i] - 1); num.push_back(a[i]); num.push_back(a[i] + 1); if (q[i] == 2) { num.push_back(b[i] - 1); num.push_back(b[i]); num.push_back(b[i] + 1); } } sort(ALL(num)); num.erase(unique(ALL(num)), num.end()); ll su = num.size(); segtree<S, op, e> seg(su + 1); rrep(i, num.size() - 1) { auto itr = lower_bound(ALL(numnum), num[i]); ll l = itr - numnum.begin(); ll haba = num[i] - num[i - 1]; seg.set(i, S{A[l] * haba, A[l] * haba, A[l] * haba, A[l] * haba}); } rrep(i, Q) { if (q[i] == 1) { ll l = lower_bound(ALL(num), a[i]) - num.begin(); seg.set(l, S{b[i], b[i], b[i], b[i]}); } else { ll l = lower_bound(ALL(num), a[i]) - num.begin(); ll r = lower_bound(ALL(num), b[i]) - num.begin(); cout << seg.prod(l, r + 1).kukan_max << endl; } } }