제출 #304557

#제출 시각아이디문제언어결과실행 시간메모리
304557vipghn2003Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
129 ms13176 KiB
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N=2e5+5;
int n,q,s,t,a[N],b[N],pos,neg;

void add(int x)
{
    if(x>0) pos+=x;
    else neg+=-x;
}

void del(int x)
{
    if(x>0) pos-=x;
    else neg-=-x;
}


main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>q>>s>>t;
    for(int i=0;i<=n;i++)
    {
        cin>>a[i];
        if(i)
        {
            b[i]=a[i]-a[i-1];
            add(b[i]);
        }
    }
    while(q--)
    {
        int l,r,x;
        cin>>l>>r>>x;
        if(l>=1)
        {
            del(b[l]);
            b[l]+=x;
            add(b[l]);
        }
        if(r+1<=n)
        {
            del(b[r+1]);
            b[r+1]-=x;
            add(b[r+1]);
        }
        cout<<neg*t-pos*s<<'\n';
    }
}

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

foehn_phenomena.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main()
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...