제출 #877442

#제출 시각아이디문제언어결과실행 시간메모리
877442Beerus13Foehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
75 ms8700 KiB
#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;
    }
    int old_val, prev, nxt;
    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;
}

컴파일 시 표준 에러 (stderr) 메시지

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:26:9: warning: unused variable 'old_val' [-Wunused-variable]
   26 |     int old_val, prev, nxt;
      |         ^~~~~~~
foehn_phenomena.cpp:26:18: warning: unused variable 'prev' [-Wunused-variable]
   26 |     int old_val, prev, nxt;
      |                  ^~~~
foehn_phenomena.cpp:26:24: warning: unused variable 'nxt' [-Wunused-variable]
   26 |     int old_val, prev, nxt;
      |                        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...