Submission #134518

# Submission time Handle Problem Language Result Execution time Memory
134518 2019-07-23T02:13:04 Z junodeveloper Foehn Phenomena (JOI17_foehn_phenomena) C++14
100 / 100
186 ms 13304 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, Q;
ll S, T, a[200010], b[200010];
int main() {
	scanf("%d%d%lld%lld",&n,&Q,&S,&T);
	int i; ll sum = 0;
	for(i=0;i<=n;i++) {
		scanf("%lld",a+i);
		if(i) {
			b[i]=a[i]-a[i-1];
			if(b[i]>0) sum-=S*b[i];
			else sum-=T*b[i];
		}
	}
	while(Q--) {
		int l, r; ll x;
		scanf("%d%d%lld",&l,&r,&x);
		if(b[l]>0) sum+=S*b[l];
		else sum+=T*b[l];
		if(b[r+1]>0) sum+=S*b[r+1];
		else sum+=T*b[r+1];
		b[l]+=x;
		if(r+1<=n)b[r+1]-=x;
		if(b[l]>0) sum-=S*b[l];
		else sum-=T*b[l];
		if(b[r+1]>0) sum-=S*b[r+1];
		else sum-=T*b[r+1];
		printf("%lld\n",sum);
	}
	return 0;
}

Compilation message

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%lld%lld",&n,&Q,&S,&T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",a+i);
   ~~~~~^~~~~~~~~~~~
foehn_phenomena.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%lld",&l,&r,&x);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 3 ms 484 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 4 ms 504 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 440 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 4 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 164 ms 10360 KB Output is correct
2 Correct 170 ms 10872 KB Output is correct
3 Correct 166 ms 11512 KB Output is correct
4 Correct 149 ms 11000 KB Output is correct
5 Correct 157 ms 12024 KB Output is correct
6 Correct 131 ms 11000 KB Output is correct
7 Correct 130 ms 11000 KB Output is correct
8 Correct 171 ms 11896 KB Output is correct
9 Correct 169 ms 12152 KB Output is correct
10 Correct 165 ms 10872 KB Output is correct
11 Correct 113 ms 10920 KB Output is correct
12 Correct 125 ms 11768 KB Output is correct
13 Correct 124 ms 11896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 3 ms 484 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 4 ms 504 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 440 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 4 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 164 ms 10360 KB Output is correct
23 Correct 170 ms 10872 KB Output is correct
24 Correct 166 ms 11512 KB Output is correct
25 Correct 149 ms 11000 KB Output is correct
26 Correct 157 ms 12024 KB Output is correct
27 Correct 131 ms 11000 KB Output is correct
28 Correct 130 ms 11000 KB Output is correct
29 Correct 171 ms 11896 KB Output is correct
30 Correct 169 ms 12152 KB Output is correct
31 Correct 165 ms 10872 KB Output is correct
32 Correct 113 ms 10920 KB Output is correct
33 Correct 125 ms 11768 KB Output is correct
34 Correct 124 ms 11896 KB Output is correct
35 Correct 169 ms 10480 KB Output is correct
36 Correct 169 ms 12028 KB Output is correct
37 Correct 171 ms 12664 KB Output is correct
38 Correct 172 ms 12580 KB Output is correct
39 Correct 186 ms 12536 KB Output is correct
40 Correct 175 ms 12536 KB Output is correct
41 Correct 172 ms 12280 KB Output is correct
42 Correct 185 ms 12408 KB Output is correct
43 Correct 171 ms 11672 KB Output is correct
44 Correct 176 ms 12088 KB Output is correct
45 Correct 176 ms 12152 KB Output is correct
46 Correct 166 ms 13304 KB Output is correct
47 Correct 132 ms 11732 KB Output is correct
48 Correct 143 ms 11712 KB Output is correct
49 Correct 167 ms 10744 KB Output is correct
50 Correct 121 ms 11512 KB Output is correct
51 Correct 126 ms 11896 KB Output is correct
52 Correct 177 ms 11684 KB Output is correct