結果

問題 No.3411 Range Clamp Sum
コンテスト
ユーザー nikoro256
提出日時 2025-12-18 00:51:22
言語 C++17(clang)
(17.0.6 + boost 1.89.0)
結果
AC  
実行時間 1,384 ms / 10,000 ms
コード長 860 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,841 ms
コンパイル使用メモリ 172,160 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-18 00:51:46
合計ジャッジ時間 20,382 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, Q;
    cin >> N >> Q;

    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<long long> answers;

    for (int _ = 0; _ < Q; _++) {
        int type;
        cin >> type;

        if (type == 1) {
            int x;
            long long y;
            cin >> x >> y;
            A[x - 1] = y;
        }

        if (type == 2) {
            int l, r;
            long long a, b;
            cin >> l >> r >> a >> b;

            long long ans = 0;
            for (int i = l - 1; i < r; i++) {
                ans += max(a, min(b, A[i]));
            }
            answers.push_back(ans);
        }
    }

    for (auto v : answers) {
        cout << v << '\n';
    }

    return 0;
}
0