답안 #985514

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985514 2024-05-18T02:36:59 Z blackavar Sjeckanje (COCI21_sjeckanje) C++14
0 / 110
1 ms 4444 KB
#include <bits/stdc++.h>
using namespace std;

long long n, a[1000005], d[1000005], q, dp[1000005];

struct Node{

};

void build(long long id, long long l, long long r) {

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i < n; i++) d[i] = a[i] - a[i + 1];
    dp[0] = 0;
    while (q--) {
        long long l, r, x;
        cin >> l >> r >> x;
        d[l - 1] -= x;
        d[r] += x;
        d[0] = d[1];
        for (int i = 1; i < n; i++) {
            if (d[i] * d[i - 1] > 0) dp[i] = dp[i - 1] + abs(d[i]);
            else dp[i] = dp[i - 2] + abs(d[i]);
        }
        cout << dp[n - 1] << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -