CSES - Datatähti 2018 loppu - Results
Submission details
Task:Tietoverkko
Sender:ArktinenKarpalo
Submission time:2018-01-18 16:02:14 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.05 s1details
#20.05 s1details
#30.05 s1details
#40.06 s1details
#50.04 s1details
#60.17 s2details
#70.16 s2details
#80.18 s2details
#90.16 s2details
#100.17 s2details

Code

#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n, f;
vector<ll> x;
ll mi, ma, a, b, as, bs, sum;

int main() {
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> f;
		x.push_back(f);
		sum += f;
	}
	mi = max(mi, x[0]);
	mi = max(mi, x[n-1]);
	ma= max(ma, x[0]);
	ma = max(ma, x[n-1]);

	as = sum;
	for(int i=0; i<n; i++) {
		a += x[i];
		as -= x[i];
		if(as<a) {
			a-=abs(as-a);
			ma = max(ma, a);
		}
		ma = max(a, ma);
	}

	b+=x[n-1];
	bs = sum;
	bs-=x[n-1];
	for(int i=n-2; i>=1; i--) {
		mi = max(mi, b);
		bs-=x[i];
		b-=x[i];
		if(b<0)
			b = abs(b);
		if(bs<b)
			b += abs(b-bs);
		cout << b <<endl;
	}

	cout << mi << " " << ma;


}

Test details

Test 1

Group: 1

Verdict:

input
100
16 88
6 77
60 92
98 64
...

correct output
97

user output
8
21
53
32
47
...

Test 2

Group: 1

Verdict:

input
100
97 41
95 93
79 60
5 4
...

correct output
95

user output
40
13
36
55
46
...

Test 3

Group: 1

Verdict:

input
100
87 24
21 49
86 85
42 32
...

correct output
90

user output
4
0
70
62
23
...

Test 4

Group: 1

Verdict:

input
100
30 24
54 79
51 6
80 29
...

correct output
50

user output
30
23
20
57
3
...

Test 5

Group: 1

Verdict:

input
100
11 27
54 59
100 90
2 95
...

correct output
0

user output
89
85
60
5
27
...

Test 6

Group: 2

Verdict:

input
100000
98276 76171
70684 49183
48756 661
17166 16972
...

correct output
99997

user output
16232
8395
57040
30093
23537
...

Test 7

Group: 2

Verdict:

input
100000
35903 47275
13566 84
58018 42495
57071 4451
...

correct output
99995

user output
18288
4033
93121
74441
5999
...

Test 8

Group: 2

Verdict:

input
100000
79209 94485
60266 86793
27501 19927
13544 59730
...

correct output
99000

user output
45745
31213
4193
75379
18842
...

Test 9

Group: 2

Verdict:

input
100000
68402 82703
12892 46068
60013 40753
26168 34434
...

correct output
90000

user output
13510
13120
62249
47555
36454
...

Test 10

Group: 2

Verdict:

input
100000
37330 74855
54324 45726
61652 15611
79081 47339
...

correct output
0

user output
30958
10829
51424
38090
56616
...