Submission #289627

#TimeUsernameProblemLanguageResultExecution timeMemory
289627rocks03Foehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
1089 ms3704 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pld pair<long double, int> #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define ff first #define ss second #define SZ(x) ((int)(x).size()) #define ld long double mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 2e5+100; int N, Q; ll S, T, a[MAXN]; void read(){ cin >> N >> Q >> S >> T; for(int i = 0; i <= N; i++){ cin >> a[i]; } } ll calcola(){ int t = 0; for(int i = 0; i < N; i++){ if(a[i] < a[i+1]) t -= (a[i+1] - a[i]) * S; else if(a[i] > a[i+1]) t += (a[i] - a[i+1]) * T; } return t; } void solve(){ read(); while(Q--){ int l, r, x; cin >> l >> r >> x; for(int i = l; i <= r; i++) a[i] += x; cout << calcola() << "\n"; } } int main(){ ios_base::sync_with_stdio(false); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...