제출 #209157

#제출 시각아이디문제언어결과실행 시간메모리
209157cstuartFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
160 ms7288 KiB
#define _USE_MATH_DEFINES 1 #define _EXT_CODECVT_SPECIALIZATIONS_H 1 #define _EXT_ENC_FILEBUF_H 1 #include <bits/stdc++.h> #include <bits/extc++.h> using namespace std; using namespace __gnu_pbds; #define MOD 1000000007ll #define EPS 1e-9 typedef long long ll; typedef long double ld; typedef pair <ll,ll> pl; typedef tuple <ll,ll,ll> tl; ll N, Q, S, T, H[200005], D[200005], L, R, X, A; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> Q >> S >> T >> H[0]; A = 0; for (ll i = 1; i <= N; i++) { cin >> H[i]; D[i] = H[i] - H[i-1]; if (D[i] > 0) A -= D[i] * S; else A -= D[i] * T; } //cout << "init A " << A << "\n"; for (ll q = 1; q <= Q; q++) { cin >> L >> R >> X; if (D[L] > 0) A += D[L] * S; else A += D[L] * T; if (R < N) { if (D[R+1] > 0) A += D[R+1] * S; else A += D[R+1] * T; } D[L] += X; D[R+1] -= X; if (D[L] > 0) A -= D[L] * S; else A -= D[L] * T; if (R < N) { if (D[R+1] > 0) A -= D[R+1] * S; else A -= D[R+1] * T; } cout << A << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...