Submission #751114

#TimeUsernameProblemLanguageResultExecution timeMemory
751114vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
1086 ms1852 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long // s min t plus // kanan lebih tinggi -> min, kiri lebih tinggi -> plus // baru nyadar ini O(n*q) wkwk tle deh ll n, q, s, t; ll h[200005]; int main(){ cin>>n>>q>>s>>t; for (int i = 0; i <= n; ++i){ cin>>h[i]; } for (int i = 0; i < q; ++i){ ll lidx, ridx, w; cin>>lidx>>ridx>>w; ll scnt = 0; ll tcnt = 0; for (int j = lidx; j <= ridx; ++j){ h[j] += w; } for (int j = 0; j < n ; ++j){ if (h[j+1] >= h[j]){ scnt -= h[j+1] - h[j]; } else { tcnt += h[j] - h[j+1]; } } // for (int j = 0; j <= n ; ++j){ // if (j==n){ // cout<<h[j]<<endl; // } else { // cout<<h[j]<<" "; // } // } // cout<<"scnt = "<<scnt<<" "<<"tcnt ="<<tcnt<<endl; cout<<(s*scnt) + (t*tcnt)<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...