Submission #46637

#TimeUsernameProblemLanguageResultExecution timeMemory
46637maksim_gaponovFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1075 ms2292 KiB
#define _CRT_SECURE_NO_WARNINGS #ifdef _DEBUG #define FILE_IN "input.txt" #define FILE_OUT "output.txt" #endif #include <iostream> #include <cstdlib> #include <climits> #include <set> #include <map> #include <cstdio> #include <string> #include <cstring> #include <cassert> #include <vector> #include <algorithm> #include <queue> using namespace std; typedef long long ll; void openFiles() { #ifdef _DEBUG assert(freopen(FILE_IN, "r", stdin)); assert(freopen(FILE_OUT, "w", stdout)); #endif } vector<ll> a; int main() { openFiles(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q, s, t; cin >> n >> q >> s >> t; n++; a.resize(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < q; j++) { int l, r; ll x; cin >> l >> r >> x; for (int i = l; i <= r; i++) { a[i] += x; } ll res = 0; for (int i = 1; i < n; i++) { ll diff = abs(a[i] - a[i - 1]); if (a[i] > a[i - 1]) { res -= s * diff; } else { res += t * diff; } } cout << res << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...