제출 #1286086

#제출 시각아이디문제언어결과실행 시간메모리
1286086ilovewaguriFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
13 ms1032 KiB
#include<bits/stdc++.h>
using namespace std;
#define NAME "TEST"
#define nl '\n'
#define allofa(x,sz) x,x+sz+1
#define allof(x) x.begin(),x.end()
#define mset(x,val) memset(x,val,sizeof(x))
template<class X,class Y> bool minimize(X &a, Y b){if(a>b){a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b){a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e18;
const int INF = (int)1e9;
const int MAXN = (int)2e5+5;
int a[MAXN];
int n,q,s,t;

void ccps() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    if(fopen(NAME".inp","r")) {
        freopen(NAME".inp","r",stdin);
        freopen(NAME".out","w",stdout);
    }
}

namespace sub1 {
    const int N = 2010;
    ll diff[N],pref[N];

    bool check() {
        return n<=2000 and q<=2000;
    }

    void sol() {
        diff[0]=a[0];
        for (int i = 1; i<=n; i++) {
            diff[i]=a[i]-a[i-1];
        }
        while(q--) {
            int l,r,w; cin >> l >> r >> w;
            diff[l]+=w;
            diff[r+1]-=w;
            for (int i = 1; i<=n; i++) {
                pref[i]=pref[i-1]+diff[i];
            }
            ll res = 0;
//            for (int i = 1; i<=n; i++) {
//                cerr << pref[i] << " ";
//            }
//            cerr << nl;
            for (int i = 1; i<=n; i++) {
                if(pref[i]>pref[i-1]) res-=1LL*s*llabs(pref[i]-pref[i-1]);
                else res+=1LL*t*llabs(pref[i]-pref[i-1]);
//                cerr << res << " ";
            }
//            cerr << nl << nl;
            cout << res << nl;
        }
    }
}

signed main() {
    ccps();
    cin >> n >> q >> s >> t;
    for (int i = 0; i<=n; i++) {
        cin >> a[i];
    }
    if(sub1::check()) sub1::sol();
}

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

foehn_phenomena.cpp: In function 'void ccps()':
foehn_phenomena.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(NAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(NAME".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...