제출 #1017654

#제출 시각아이디문제언어결과실행 시간메모리
1017654vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
73 ms13236 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define tobit(n) bitset<20>(n) //выводит 20 элементов в битовую систему #define all(v) (v).begin(), (v).end() #define rtt(v, k) rotate(v.begin(), v.begin() + k, v.end()); //move k elements back signed main(){ int N, Q, S, T, result = 0; cin >> N >> Q >> S >> T; S = S * (-1); T = T * (-1); vector<int> v(N + 1), answer(N); for(int i = 0; i < N + 1; i++) cin >> v[i]; for(int i = 0; i < N; i++){ answer[i] = v[i + 1] - v[i]; if(answer[i] > 0) result += S * answer[i]; else result += T*answer[i]; } for(int i = 0; i < Q; i++){ int L, R, X; cin >> L >> R >> X; if(answer[L - 1] > 0) result -= S * answer[L - 1]; else result -= T * answer[L - 1]; if(R < N){ if(answer[R] > 0) result -= S * answer[R]; else result -= T * answer[R]; } answer[L - 1] += X; if(R < N) answer[R] -= X; if(answer[L - 1] > 0) result += S * answer[L - 1]; else result += T * answer[L - 1]; if(R < N){ if(answer[R] > 0) result += S * answer[R]; else result += T * answer[R]; } cout << result << "\n"; } } // NEED TO FAST CIN && COUT // const int fastIO = [](){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...