제출 #1267347

#제출 시각아이디문제언어결과실행 시간메모리
1267347jj_masterFoehn Phenomena (JOI17_foehn_phenomena)C++20
0 / 100
1093 ms3708 KiB

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

#define int long long 
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void sol()
{
    int n, q, s, t;
    cin >> n >> q >> s >> t;
    vector<int> a;
    int ai;
    for(int i = 0; i < n + 1; i++) {
        cin >> ai;
        a.pb(ai);
    }
    vector<int> b = a;
    int x, y, z;
    int wind = 0;
    for(int i = 0; i < q; i++) {
        cin >> x >> y >> z;
        for(int j = x; j <= y; j++) a[j] += z;
        for(int j = 0; j < a.size() - 1; j++) {
            if(a[j] < a[j + 1]) {
                wind -= s * (a[j + 1] - a[j]);
            } else {
                wind += t * (a[j] - a[j + 1]);
            }
        }
        cout << wind << '\n';
        wind = 0;
        a = b;
    }
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    sol();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...