Submission #50253

# Submission time Handle Problem Language Result Execution time Memory
50253 2018-06-08T13:07:50 Z gs13105 Foehn Phenomena (JOI17_foehn_phenomena) C++17
100 / 100
238 ms 167876 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>

using namespace std;

const int MAXN = 200000;

long long arr[MAXN + 10];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, q, s, t, i;
    scanf("%d%d%d%d", &n, &q, &s, &t);

    int a, p;
    for(i = 0; i < n + 1; i++)
    {
        scanf("%d", &a);
        if(i != 0)
            arr[i] = a - p;

        p = a;
    }

    long long c = 0;
    for(i = 1; i <= n; i++)
        c -= 1LL * (arr[i] > 0 ? s : t) * arr[i];

    for(i = 0; i < q; i++)
    {
        int l, r, x;
        scanf("%d%d%d", &l, &r, &x);

        c += 1LL * (arr[l] > 0 ? s : t) * arr[l];
        arr[l] += x;
        c -= 1LL * (arr[l] > 0 ? s : t) * arr[l];

        r++;
        if(r != n + 1)
        {
            c += 1LL * (arr[r] > 0 ? s : t) * arr[r];
            arr[r] -= x;
            c -= 1LL * (arr[r] > 0 ? s : t) * arr[r];
        }

        printf("%lld\n", c);
    }
    return 0;
}

Compilation message

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:30: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:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
foehn_phenomena.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &l, &r, &x);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 556 KB Output is correct
3 Correct 4 ms 668 KB Output is correct
4 Correct 6 ms 808 KB Output is correct
5 Correct 5 ms 808 KB Output is correct
6 Correct 4 ms 832 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 5 ms 944 KB Output is correct
9 Correct 4 ms 1032 KB Output is correct
10 Correct 4 ms 1040 KB Output is correct
11 Correct 4 ms 1132 KB Output is correct
12 Correct 4 ms 1184 KB Output is correct
13 Correct 4 ms 1196 KB Output is correct
14 Correct 4 ms 1240 KB Output is correct
15 Correct 4 ms 1328 KB Output is correct
16 Correct 3 ms 1420 KB Output is correct
17 Correct 4 ms 1420 KB Output is correct
18 Correct 4 ms 1436 KB Output is correct
19 Correct 2 ms 1472 KB Output is correct
20 Correct 2 ms 1476 KB Output is correct
21 Correct 2 ms 1476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 9896 KB Output is correct
2 Correct 238 ms 15908 KB Output is correct
3 Correct 186 ms 21996 KB Output is correct
4 Correct 179 ms 26744 KB Output is correct
5 Correct 160 ms 33556 KB Output is correct
6 Correct 159 ms 38660 KB Output is correct
7 Correct 161 ms 43124 KB Output is correct
8 Correct 195 ms 48696 KB Output is correct
9 Correct 202 ms 54568 KB Output is correct
10 Correct 173 ms 58796 KB Output is correct
11 Correct 111 ms 64196 KB Output is correct
12 Correct 123 ms 69548 KB Output is correct
13 Correct 123 ms 74548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 556 KB Output is correct
3 Correct 4 ms 668 KB Output is correct
4 Correct 6 ms 808 KB Output is correct
5 Correct 5 ms 808 KB Output is correct
6 Correct 4 ms 832 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 5 ms 944 KB Output is correct
9 Correct 4 ms 1032 KB Output is correct
10 Correct 4 ms 1040 KB Output is correct
11 Correct 4 ms 1132 KB Output is correct
12 Correct 4 ms 1184 KB Output is correct
13 Correct 4 ms 1196 KB Output is correct
14 Correct 4 ms 1240 KB Output is correct
15 Correct 4 ms 1328 KB Output is correct
16 Correct 3 ms 1420 KB Output is correct
17 Correct 4 ms 1420 KB Output is correct
18 Correct 4 ms 1436 KB Output is correct
19 Correct 2 ms 1472 KB Output is correct
20 Correct 2 ms 1476 KB Output is correct
21 Correct 2 ms 1476 KB Output is correct
22 Correct 193 ms 9896 KB Output is correct
23 Correct 238 ms 15908 KB Output is correct
24 Correct 186 ms 21996 KB Output is correct
25 Correct 179 ms 26744 KB Output is correct
26 Correct 160 ms 33556 KB Output is correct
27 Correct 159 ms 38660 KB Output is correct
28 Correct 161 ms 43124 KB Output is correct
29 Correct 195 ms 48696 KB Output is correct
30 Correct 202 ms 54568 KB Output is correct
31 Correct 173 ms 58796 KB Output is correct
32 Correct 111 ms 64196 KB Output is correct
33 Correct 123 ms 69548 KB Output is correct
34 Correct 123 ms 74548 KB Output is correct
35 Correct 177 ms 77808 KB Output is correct
36 Correct 186 ms 84700 KB Output is correct
37 Correct 202 ms 90852 KB Output is correct
38 Correct 167 ms 96072 KB Output is correct
39 Correct 197 ms 101568 KB Output is correct
40 Correct 163 ms 106860 KB Output is correct
41 Correct 208 ms 112152 KB Output is correct
42 Correct 187 ms 117708 KB Output is correct
43 Correct 211 ms 122532 KB Output is correct
44 Correct 211 ms 128188 KB Output is correct
45 Correct 179 ms 133696 KB Output is correct
46 Correct 176 ms 140492 KB Output is correct
47 Correct 227 ms 145008 KB Output is correct
48 Correct 157 ms 149688 KB Output is correct
49 Correct 147 ms 153064 KB Output is correct
50 Correct 200 ms 158508 KB Output is correct
51 Correct 149 ms 163256 KB Output is correct
52 Correct 135 ms 167876 KB Output is correct