제출 #51498

#제출 시각아이디문제언어결과실행 시간메모리
51498atoizFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
731 ms4892 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cstdlib> #include <cmath> using namespace std; int N, Q, S, T; long long point(int a) { long long cur; if (a > 0) cur = -S * a; else cur = -T * a; return cur; } int main() { cin >> N >> Q >> S >> T; vector<int> spots(N+1, 0), diff(N+2, 0); for (int i = 0; i <= N; ++i) cin >> spots[i]; for (int i = 0; i < N; ++i) diff[i] = spots[i+1] - spots[i]; long long cur = 0; for (int i = 0; i < N; ++i) { cur += point(diff[i]); } // cout << cur << endl; for (int q = 0; q < Q; ++q) { int l, r, x; cin >> l >> r >> x; if (l > 0) { cur -= point(diff[l-1]); diff[l-1] += x; cur += point(diff[l-1]); } if (r < N) { cur -= point(diff[r]); diff[r] -= x; cur += point(diff[r]); } cout << cur << endl; } // for (int i = 0; i < N; ++i) cout << diff[i] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...