답안 #877448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
877448 2023-11-23T08:42:48 Z Beerus13 Foehn Phenomena (JOI17_foehn_phenomena) C++14
0 / 100
74 ms 3368 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, int>
#define fi first
#define se second
const int N = 2e5 + 5;

int n, q, s, t, ans = 0;
int kc[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> q >> s >> t;
    int pre_val;
    for(int i = 0; i <= n; ++i) {
        int x; cin >> x; 
        if(i) {
            kc[i] = pre_val - x;
            if(kc[i] >= 0) ans += t * kc[i];
            else ans += s * kc[i];
        }
        pre_val = x;
    }
    while(q--) {
        int l, r, x; cin >> l >> r >> x;
        if(kc[l] >= 0) ans -= kc[l] * t;
        else ans -= kc[l] * s;
        kc[l] -= x;
        if(kc[l] >= 0) ans += kc[l] * t;
        else ans += kc[l] * s;

        if(r < n) {
            if(kc[r + 1] >= 0) ans -= kc[r + 1] * t;
            else ans -= kc[r + 1] * s;
            kc[r + 1] += x;
            if(kc[r + 1] >= 0) ans += kc[r + 1] * t;
            else ans += kc[r + 1] * s;
        }
        cout << ans << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 2516 KB Output is correct
2 Correct 74 ms 3368 KB Output is correct
3 Incorrect 67 ms 3088 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -