이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long calc(vector<int>& a) {
    vector<long long> dp(a.size(), 0); // max val if ends in i
    dp[0] = 0;
    for (int i = 1; i < a.size(); ++i) {
        int maxVal = a[i], minVal = a[i];
        for (int j = i - 1; j >= 0; --j) {
            dp[i] = max(dp[i], dp[j] + maxVal - minVal);
            maxVal = max(maxVal, a[j]);
            minVal = min(minVal, a[j]);
        }
        dp[i] = max(dp[i], (long long)maxVal - minVal);
    }
    return dp.back();
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (auto& i : a) {
        cin >> i;
    }
    while (q--) {
        int l, r, x;
        cin >> l >> r >> x;
        --l, --r;
        for (int i = l; i <= r; ++i) {
            a[i] += x;
        }
        cout << calc(a) << '\n';
    }
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'long long int calc(std::vector<int>&)':
Main.cpp:8:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 1; i < a.size(); ++i) {
      |                     ~~^~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |