結果
| 問題 | 
                            No.2333 Slime Structure
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kwm_t
                         | 
                    
| 提出日時 | 2023-05-31 21:22:42 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,366 bytes | 
| コンパイル時間 | 4,291 ms | 
| コンパイル使用メモリ | 259,076 KB | 
| 最終ジャッジ日時 | 2025-02-13 17:06:58 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 WA * 26 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
struct S {
	long long lmax;
	long long rmax;
	long long max;
	long long sum;
};
S op(S a, S b) {
	return S{ max(a.lmax, a.sum + b.lmax),
			 max(b.rmax, b.sum + a.rmax),
			 max(max(a.max, b.max), a.rmax + b.lmax),
			 a.sum + b.sum };
}
S e() { return S{ -LINF, -LINF, -LINF, 0 }; }
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	vector<long long>a(n), b(n), sb(n + 1);
	rep(i, n)cin >> a[i] >> b[i];
	rep(i, n)sb[i + 1] = sb[i] + b[i];
	vector<long long>tmp = { 0 };
	rep(i, n) {
		tmp.push_back(sb[i + 1]);
	}
	int q; cin >> q;
	vector<long long>t(q), l(q), r(q);
	rep(i, q) {
		cin >> t[i] >> l[i] >> r[i];
		l[i]--;
		if (1 == t[i]) {
			tmp.push_back(l[i]);
		}
		else {
			tmp.push_back(l[i]);
			tmp.push_back(r[i]);
		}
	}
	sort(all(tmp));
	tmp.erase(unique(all(tmp)), tmp.end());
	int sz = tmp.size();
	segtree<S, op, e>seg(sz - 1);
	auto set = [&](int idx, long long sz, long long val)->void {
		if (val >= 0) {
			seg.set(idx, { sz* val, sz*val, sz*val, sz*val });
		}
		else {
			seg.set(idx, { val, val, val, sz*val });
		}
	};
	rep(i, sz - 1) {
		long long sz = tmp[i + 1] - tmp[i];
		int idx = upper_bound(all(sb), tmp[i]) - sb.begin();
		set(i, sz, a[idx - 1]);
	}
	rep(i, q) {
		if (1 == t[i]) {
			int idx = lower_bound(all(tmp), l[i]) - tmp.begin();
			set(idx, 1, r[i]);
		}
		else {
			int idxl = lower_bound(all(tmp), l[i]) - tmp.begin();
			int idxr = lower_bound(all(tmp), r[i]) - tmp.begin();
			auto get = seg.prod(idxl, idxr);
			cout << get.max << endl;
		}
	}
	return 0;
}
            
            
            
        
            
kwm_t