Submission #781591

#TimeUsernameProblemLanguageResultExecution timeMemory
781591RecursiveCoFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
98 ms13192 KiB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long

signed main() {
    improvePerformance;
    //getTest;

    //eachTest {
        get(n);
        get(q);
        get(s);
        get(t);
        vector<int> pos;
        forto(n + 1, i) {
            get(x);
            pos.push_back(x);
        }
        vector<int> delta;
        forto(n, i) delta.push_back(pos[i + 1] - pos[i]);
        int ans = 0;
        forto(n, i) {
            if (delta[i] >= 0) ans -= s * delta[i];
            else ans -= t * delta[i];
        }
        forto(q, i) {
            get(l);
            get(r);
            l--;
            r--;
            get(x);
            ans += delta[l] >= 0? s * delta[l]: t * delta[l];
            delta[l] += x;
            ans -= delta[l] >= 0? s * delta[l]: t * delta[l];
            if (r != n - 1) {
                ans += delta[r + 1] >= 0? s * delta[r + 1]: t * delta[r + 1];
                delta[r + 1] -= x;
                ans -= delta[r + 1] >= 0? s * delta[r + 1]: t * delta[r + 1];
            }
            out(ans);
            out("\n");
        }
        //out("\n");
    //}
}

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
foehn_phenomena.cpp:25:9: note: in expansion of macro 'get'
   25 |         get(n);
      |         ^~~
foehn_phenomena.cpp:10:23: warning: unnecessary parentheses in declaration of 'q' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
foehn_phenomena.cpp:26:9: note: in expansion of macro 'get'
   26 |         get(q);
      |         ^~~
foehn_phenomena.cpp:10:23: warning: unnecessary parentheses in declaration of 's' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
foehn_phenomena.cpp:27:9: note: in expansion of macro 'get'
   27 |         get(s);
      |         ^~~
foehn_phenomena.cpp:10:23: warning: unnecessary parentheses in declaration of 't' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
foehn_phenomena.cpp:28:9: note: in expansion of macro 'get'
   28 |         get(t);
      |         ^~~
foehn_phenomena.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
foehn_phenomena.cpp:30:9: note: in expansion of macro 'forto'
   30 |         forto(n + 1, i) {
      |         ^~~~~
foehn_phenomena.cpp:10:23: warning: unnecessary parentheses in declaration of 'x' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
foehn_phenomena.cpp:31:13: note: in expansion of macro 'get'
   31 |             get(x);
      |             ^~~
foehn_phenomena.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
foehn_phenomena.cpp:35:9: note: in expansion of macro 'forto'
   35 |         forto(n, i) delta.push_back(pos[i + 1] - pos[i]);
      |         ^~~~~
foehn_phenomena.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
foehn_phenomena.cpp:37:9: note: in expansion of macro 'forto'
   37 |         forto(n, i) {
      |         ^~~~~
foehn_phenomena.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
foehn_phenomena.cpp:41:9: note: in expansion of macro 'forto'
   41 |         forto(q, i) {
      |         ^~~~~
foehn_phenomena.cpp:10:23: warning: unnecessary parentheses in declaration of 'l' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
foehn_phenomena.cpp:42:13: note: in expansion of macro 'get'
   42 |             get(l);
      |             ^~~
foehn_phenomena.cpp:10:23: warning: unnecessary parentheses in declaration of 'r' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
foehn_phenomena.cpp:43:13: note: in expansion of macro 'get'
   43 |             get(r);
      |             ^~~
foehn_phenomena.cpp:10:23: warning: unnecessary parentheses in declaration of 'x' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
foehn_phenomena.cpp:46:13: note: in expansion of macro 'get'
   46 |             get(x);
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...