結果

問題 No.3411 Range Clamp Sum
コンテスト
ユーザー AwashAmityOak
提出日時 2025-12-17 04:34:19
言語 C++23
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 1,413 ms / 10,000 ms
コード長 1,224 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,763 ms
コンパイル使用メモリ 278,488 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-17 23:38:53
合計ジャッジ時間 20,124 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

#define int long long
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N, Q;
    cin >> N >> Q;
    assert(1 <= N && N <= 100000);
    assert(1 <= Q && Q <= 100000);
    
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        assert(0 <= A[i] && A[i] <= 100000);
    }
    
    rep(q, Q) {
        int t;
        cin >> t;
        assert(t == 1 || t == 2);
        
        if (t == 1) {
            int x, y;
            cin >> x >> y;
            assert(1 <= x && x <= N);
            assert(0 <= y && y <= 100000);
            --x;
            
            A[x] = y;
        } else {
            int l, r, a, b;
            cin >> l >> r >> a >> b;
            assert(1 <= l && l <= r && r <= N);
            assert(0 <= a && a <= 100000);
            assert(0 <= b && b <= 100000);
            --l;
            
            if (a > b) {
                cout << (a * (r - l)) << '\n';
            } else {
                int ans = 0;
                for (int i = l; i < r; ++i) ans += clamp(A[i], a, b);
                cout << ans << '\n';
            }
        }
    }
}
0