답안 #129549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129549 2019-07-12T13:32:19 Z miguel Foehn Phenomena (JOI17_foehn_phenomena) C++14
0 / 100
664 ms 9632 KB
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 1e9 + 7;

int n, d[200002], a[200002], q, s, t;

int temp(int x){
    if(x>0) return s*x*(-1);
    else return t*abs(x);
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>q>>s>>t;
    for(int i=0; i<=n; i++) cin>>a[i];
    for(int i=1; i<=n; i++) d[i]=a[i]-a[i-1];
    int ans=0;
    for(int i=1; i<=n; i++) ans+=temp(d[i]);
    ///cout<<ans;
    while(q--){
        int l, r, x;
        cin>>l>>r>>x;
        ans+=(temp(d[l]+x)-temp(d[l]));
        if(r+1<=n) ans+=(temp(d[r+1]-x)-temp(d[r+1]));
        d[l]+=x;
        if(r+1<=n) d[r+1]-=x;
        cout<<ans<<endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Incorrect 8 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 657 ms 3600 KB Output is correct
2 Correct 664 ms 9632 KB Output is correct
3 Incorrect 663 ms 9524 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Incorrect 8 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -