Submission #124780

# Submission time Handle Problem Language Result Execution time Memory
124780 2019-07-04T01:18:04 Z ainta Foehn Phenomena (JOI17_foehn_phenomena) C++17
100 / 100
170 ms 12408 KB
#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

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 time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 380 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 9592 KB Output is correct
2 Correct 162 ms 10208 KB Output is correct
3 Correct 164 ms 10744 KB Output is correct
4 Correct 144 ms 10104 KB Output is correct
5 Correct 155 ms 11460 KB Output is correct
6 Correct 135 ms 10232 KB Output is correct
7 Correct 130 ms 10232 KB Output is correct
8 Correct 169 ms 11008 KB Output is correct
9 Correct 162 ms 11384 KB Output is correct
10 Correct 161 ms 10228 KB Output is correct
11 Correct 111 ms 10232 KB Output is correct
12 Correct 120 ms 10872 KB Output is correct
13 Correct 126 ms 11156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 380 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 162 ms 9592 KB Output is correct
23 Correct 162 ms 10208 KB Output is correct
24 Correct 164 ms 10744 KB Output is correct
25 Correct 144 ms 10104 KB Output is correct
26 Correct 155 ms 11460 KB Output is correct
27 Correct 135 ms 10232 KB Output is correct
28 Correct 130 ms 10232 KB Output is correct
29 Correct 169 ms 11008 KB Output is correct
30 Correct 162 ms 11384 KB Output is correct
31 Correct 161 ms 10228 KB Output is correct
32 Correct 111 ms 10232 KB Output is correct
33 Correct 120 ms 10872 KB Output is correct
34 Correct 126 ms 11156 KB Output is correct
35 Correct 156 ms 9592 KB Output is correct
36 Correct 161 ms 11100 KB Output is correct
37 Correct 168 ms 11900 KB Output is correct
38 Correct 164 ms 11612 KB Output is correct
39 Correct 170 ms 11640 KB Output is correct
40 Correct 170 ms 11772 KB Output is correct
41 Correct 166 ms 11512 KB Output is correct
42 Correct 167 ms 11640 KB Output is correct
43 Correct 164 ms 10904 KB Output is correct
44 Correct 164 ms 11220 KB Output is correct
45 Correct 143 ms 11384 KB Output is correct
46 Correct 151 ms 12408 KB Output is correct
47 Correct 134 ms 10956 KB Output is correct
48 Correct 131 ms 10872 KB Output is correct
49 Correct 156 ms 9976 KB Output is correct
50 Correct 117 ms 10864 KB Output is correct
51 Correct 121 ms 11128 KB Output is correct
52 Correct 132 ms 11020 KB Output is correct