제출 #410582

#제출 시각아이디문제언어결과실행 시간메모리
410582TLP39Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
718 ms11512 KiB
#include <stdio.h> #include <math.h> #include <utility> #include <string.h> #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <map> using namespace std; typedef long long int ll; typedef pair<int,int> pp; int n,q; ll s,t; ll a[1000010]; ll tot=0; ll getchange(ll x) { if(x>0) return -x*s; return -x*t; } void init() { cin >> n >> q >> s >> t; cin >> a[0]; for(int i=1;i<=n;i++) { cin >> a[i]; } for(int i=n;i>0;i--) { a[i]-=a[i-1]; tot+=getchange(a[i]); } } void query(int l,int r,ll x) { tot+=(getchange(a[l]+x)-getchange(a[l])); a[l]+=x; if(r!=n) { tot+=(getchange(a[r+1]-x)-getchange(a[r+1])); a[r+1]-=x; } printf("%lld\n",tot); } int main() { int l,r; ll x; init(); while(q--) { cin >> l >> r >> x; query(l,r,x); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...