Submission #48926

#TimeUsernameProblemLanguageResultExecution timeMemory
48926AlphaRazraFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
959 ms7720 KiB
#include<bits/stdc++.h> #define pb push_back #define fs first #define sc second #define mp make_pair using namespace std; long long n,q,s,t; long long a[200005]; long long sim[200005]; pair<long long,long long> diff; int main(){ cin >> n >> q >> s >> t; for(int i = 0; i < n + 1; i++){ cin >> a[i]; } diff = mp(0,0); for(int i = 0; i < n; i++){ sim[i] = a[i + 1] - a[i]; if(sim[i] > 0){ diff.fs = diff.fs + sim[i]; }else{ diff.sc = diff.sc + abs(sim[i]); } } for(int i = 0; i < q; i++){ long long a,b,x; cin >> a >> b >> x; if(a != 0){ if(sim[a - 1] > 0){ diff.fs -= sim[a - 1]; }else{ diff.sc -= abs(sim[a - 1]); } // if(i == 2) cout << a << " " << sim[a - 1] << " " << diff.sc << " here\n"; sim[a - 1] += x; if(sim[a - 1] > 0){ diff.fs += sim[a - 1]; }else{ diff.sc += abs(sim[a - 1]); } } if(b != n){ if(sim[b] > 0){ diff.fs -= sim[b]; }else{ diff.sc -= abs(sim[b]); } sim[b] -= x; if(sim[b] > 0){ diff.fs += sim[b]; }else{ diff.sc += abs(sim[b]); } } // cout << diff.fs << " " << diff.sc << " ini\n"; cout << - diff.fs * s + diff.sc * t << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...