제출 #305778

#제출 시각아이디문제언어결과실행 시간메모리
305778couplefireFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
2 ms384 KiB
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200005

long long dif[MAXN];
int arr[MAXN];
int n, q, s, t;

int main(){
    freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q >> s >> t; t = -t;
    dif[0] = 0;
    for(int i = 0; i<=n; i++){
        int a; cin >> a;
        arr[i] = a;
        if(i >= 1) dif[i] = a-arr[i-1];
    }
    // for(int i = 1; i<=n; i++){
    //     cout << dif[i] << " ";
    // }
    // cout << endl;
    long long ans = 0;
    for(int i = 1; i<=n; i++){
        if(dif[i]>0) ans -= s*dif[i];
        else ans += t*dif[i];
    }
    // cout << ans << endl;
    while(q--){
        int l, r, x; cin >> l >> r >> x;
        int curl = dif[l];
        dif[l]+=x;
        if(curl > 0) ans += s*curl;
        else ans -= t*curl;
        if(dif[l]>0) ans -= s*dif[l];
        else ans += t*dif[l];
        if(r == n){
            cout << ans << endl;
            continue;
        }
        int curr = dif[r+1];
        dif[r+1] -= x;
        if(curr > 0) ans += s*curr;
        else ans -= t*curr;
        if(dif[r+1] > 0) ans -= s*dif[r+1];
        else ans += t*dif[r+1];
        cout << ans << endl;
    }
}

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     freopen("a.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...