Submission #124780

#TimeUsernameProblemLanguageResultExecution timeMemory
124780aintaFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
170 ms12408 KiB
#include<cstdio>
#include<algorithm>
using namespace std;
int n, Q, S, T, A[201000];
long long w[201000], res;
long long Calc(long long a) {
    if (a > 0)return -S * a;
    return -T * a;
}
int main() {
    int i, b, e, x;
    scanf("%d%d%d%d", &n, &Q, &S, &T);
    for (i = 0; i <= n; i++) {
        scanf("%d", &A[i]);
        if (i) {
            w[i] = A[i] - A[i - 1];
            res += Calc(w[i]);
        }
    }
    while (Q--) {
        scanf("%d%d%d", &b, &e, &x);
        res -= Calc(w[b]);
        w[b] += x;
        res += Calc(w[b]);
        if (e < n) {
            res -= Calc(w[e + 1]);
            w[e + 1] -= x;
            res += Calc(w[e + 1]);
        }
        printf("%lld\n", res);
    }
}

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &n, &Q, &S, &T);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
foehn_phenomena.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &b, &e, &x);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...