Submission #636905

#TimeUsernameProblemLanguageResultExecution timeMemory
636905ghostwriterFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
121 ms12364 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #endif #define st first #define nd second #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao CTL - Da Lat Cay ngay cay dem nhung deo duoc cong nhan */ const int N = 2e5 + 5; int n, q, s, t, a[N]; ll d[N], ans = 0; #define cost(d) (d > 0? -1LL * s * d : -1LL * t * d) signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen(file".inp", "r", stdin); // freopen(file".out", "w", stdout); cin >> n >> q >> s >> t; FOR(i, 0, n) cin >> a[i]; FOR(i, 1, n) d[i] = a[i] - a[i - 1]; FOR(i, 1, n) ans += cost(d[i]); WHILE(q--) { int l, r, x; cin >> l >> r >> x; ans -= cost(d[l]); d[l] += x; ans += cost(d[l]); if (r < n) { ans -= cost(d[r + 1]); d[r + 1] -= x; ans += cost(d[r + 1]); } cout << ans << '\n'; } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
foehn_phenomena.cpp:45:5: note: in expansion of macro 'FOR'
   45 |     FOR(i, 0, n) cin >> a[i];
      |     ^~~
foehn_phenomena.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
foehn_phenomena.cpp:46:5: note: in expansion of macro 'FOR'
   46 |     FOR(i, 1, n) d[i] = a[i] - a[i - 1];
      |     ^~~
foehn_phenomena.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
foehn_phenomena.cpp:47:5: note: in expansion of macro 'FOR'
   47 |     FOR(i, 1, n) ans += cost(d[i]);
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...