Submission #996932

# Submission time Handle Problem Language Result Execution time Memory
996932 2024-06-11T12:56:38 Z ag_1204 Foehn Phenomena (JOI17_foehn_phenomena) C++14
100 / 100
282 ms 13140 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n,q,s,t; cin>>n>>q>>s>>t;
    ll a[n+1],b[n];
    ll wind=0;
    for (ll i=0;i<=n;i++) {
        cin>>a[i];
        if (i>0) {
            b[i-1]=a[i]-a[i-1];
            if (b[i-1]>0) {
                wind-=s*b[i-1];
            } else {
                wind+=t*abs(b[i-1]);
            }
        }
    }
    while(q--) {
        ll l,r,x; cin>>l>>r>>x;
        b[l-1]+=x;
        ll i=b[l-1]-x, j=b[l-1];
        if (i>0 && j>0) {
            wind+=s*(i-j);
        } else if (j<=0 && i<=0) {
            wind+=t*(i-j);
        } else if (i<=0 && j>0) {
            wind-=t*abs(i);
            wind-=s*abs(j);
        } else {
            wind+=s*abs(i);
            wind+=t*abs(j);
        }
        if (r<n) {
            b[r]-=x;
            i=b[r]+x, j=b[r];
            if (i>0 && j>0) {
                wind+=s*(i-j);
            } else if (j<=0 && i<=0) {
                wind+=t*(i-j);
            } else if (i<=0 && j>0) {
                wind-=t*abs(i);
                wind-=s*abs(j);
            } else {
                wind+=s*abs(i);
                wind+=t*abs(j);
            }
        }
        cout<<wind<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
9 Correct 4 ms 672 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 360 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 3 ms 532 KB Output is correct
18 Correct 3 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 266 ms 4932 KB Output is correct
2 Correct 265 ms 10832 KB Output is correct
3 Correct 282 ms 11468 KB Output is correct
4 Correct 256 ms 11076 KB Output is correct
5 Correct 278 ms 12112 KB Output is correct
6 Correct 251 ms 11100 KB Output is correct
7 Correct 250 ms 11088 KB Output is correct
8 Correct 281 ms 11968 KB Output is correct
9 Correct 260 ms 12112 KB Output is correct
10 Correct 275 ms 10956 KB Output is correct
11 Correct 243 ms 11036 KB Output is correct
12 Correct 273 ms 11600 KB Output is correct
13 Correct 245 ms 11856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
9 Correct 4 ms 672 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 360 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 3 ms 532 KB Output is correct
18 Correct 3 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 266 ms 4932 KB Output is correct
23 Correct 265 ms 10832 KB Output is correct
24 Correct 282 ms 11468 KB Output is correct
25 Correct 256 ms 11076 KB Output is correct
26 Correct 278 ms 12112 KB Output is correct
27 Correct 251 ms 11100 KB Output is correct
28 Correct 250 ms 11088 KB Output is correct
29 Correct 281 ms 11968 KB Output is correct
30 Correct 260 ms 12112 KB Output is correct
31 Correct 275 ms 10956 KB Output is correct
32 Correct 243 ms 11036 KB Output is correct
33 Correct 273 ms 11600 KB Output is correct
34 Correct 245 ms 11856 KB Output is correct
35 Correct 271 ms 10528 KB Output is correct
36 Correct 262 ms 11876 KB Output is correct
37 Correct 276 ms 12668 KB Output is correct
38 Correct 263 ms 12368 KB Output is correct
39 Correct 260 ms 12372 KB Output is correct
40 Correct 281 ms 12392 KB Output is correct
41 Correct 265 ms 12356 KB Output is correct
42 Correct 268 ms 12632 KB Output is correct
43 Correct 282 ms 11604 KB Output is correct
44 Correct 267 ms 12116 KB Output is correct
45 Correct 259 ms 12112 KB Output is correct
46 Correct 278 ms 13140 KB Output is correct
47 Correct 253 ms 11680 KB Output is correct
48 Correct 252 ms 11672 KB Output is correct
49 Correct 253 ms 10600 KB Output is correct
50 Correct 246 ms 11600 KB Output is correct
51 Correct 259 ms 11788 KB Output is correct
52 Correct 270 ms 11600 KB Output is correct