이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef palilo
template <typename C, typename T = typename enable_if<!is_same<C, string>::value, typename C::value_type>::type>
ostream& operator<<(ostream& os, const C& container) {
os << '[';
bool first = true;
for (const auto& x : container) {
if (!first) os << ", ";
os << x;
first = false;
}
return os << ']';
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T>
void debug_msg(string name, T arg) {
cerr << name << " = " << arg << endl;
}
template <typename T1, typename... T2>
void debug_msg(string names, T1 arg, T2... args) {
cerr << names.substr(0, names.find(',')) << " = " << arg << " | ";
debug_msg(names.substr(names.find(',') + 2), args...);
}
#define debug(...) cerr << '(' << __LINE__ << ')' << ' ', debug_msg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...)
#endif
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
#ifdef palilo
freopen("in", "r", stdin);
freopen("out", "w", stdout);
#endif
int n, q;
int64_t s, t;
cin >> n >> q >> s >> t;
vector<int64_t> a(n);
{
int prv, cur;
cin >> prv;
for (auto& x : a) {
cin >> cur;
x = cur - prv;
prv = cur;
}
}
int64_t res = 0;
for (const auto& x : a) {
res -= (x < 0 ? t : s) * x;
}
for (int l, r, x; q--;) {
cin >> l >> r >> x, --l;
res += (a[l] < 0 ? t : s) * a[l];
if (r != n) res += (a[r] < 0 ? t : s) * a[r];
a[l] += x;
if (r != n) a[r] -= x;
res -= (a[l] < 0 ? t : s) * a[l];
if (r != n) res -= (a[r] < 0 ? t : s) * a[r];
cout << res << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |