제출 #46640

#제출 시각아이디문제언어결과실행 시간메모리
46640maksim_gaponovFoehn Phenomena (JOI17_foehn_phenomena)C++14
40 / 100
1082 ms5932 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; bool hack = (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; ll res = 0; if (hack) { if (r == n - 1) { a[r] += x; } res = (a[n - 1] - a[0]) * -s; } else { for (int i = l; i <= r; i++) { a[i] += x; } 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...