10773 | 2024-04-11 18:41:11 | mraron | Metróutasok | cpp17 | Accepted 100/100 | 19ms | 5772 KiB |
#include <bits/stdc++.h>
using namespace std;
const int c=200005;
long long n, sum, t[c];
int main()
{
ios_base::sync_with_stdio(false);
cin >> n;
for (int i=1; i<=n; i++) {
cin >> t[i];
sum+=t[i];
}
long long res=0, pref=0, suf=0;
for (int i=1; i<=n; i++) {
res=max(res, t[i]-pref);
long long val=(t[i]+1)/2;
if (t[i]%2==0 && pref%2!=(t[i]/2)%2) val++;
res=max(res, val);
pref+=t[i];
}
for (int i=n; i>=1; i--) {
res=max(res, t[i]-suf);
suf+=t[i];
}
cout << res << "\n";
long long s=0, maxi=0;
for (int i=1; i<=n; i++) {
s+=t[i];
if (2*s<=sum) maxi=max(maxi, s);
}
s=0;
for (int i=n; i>=1; i--) {
s+=t[i];
if (2*s<=sum) maxi=max(maxi, s);
}
cout << maxi << "\n";
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1776 KiB | ||||
2 | Accepted | 19ms | 3664 KiB | ||||
subtask2 | 12/12 | ||||||
3 | Accepted | 3ms | 2192 KiB | ||||
4 | Accepted | 2ms | 2284 KiB | ||||
5 | Accepted | 3ms | 2496 KiB | ||||
6 | Accepted | 3ms | 2664 KiB | ||||
7 | Accepted | 2ms | 2740 KiB | ||||
8 | Accepted | 2ms | 2648 KiB | ||||
9 | Accepted | 2ms | 2652 KiB | ||||
10 | Accepted | 3ms | 2936 KiB | ||||
11 | Accepted | 3ms | 2908 KiB | ||||
12 | Accepted | 3ms | 2980 KiB | ||||
13 | Accepted | 2ms | 3040 KiB | ||||
14 | Accepted | 2ms | 2948 KiB | ||||
15 | Accepted | 3ms | 3052 KiB | ||||
16 | Accepted | 3ms | 3080 KiB | ||||
subtask3 | 12/12 | ||||||
17 | Accepted | 3ms | 2192 KiB | ||||
18 | Accepted | 2ms | 2284 KiB | ||||
19 | Accepted | 3ms | 2496 KiB | ||||
20 | Accepted | 3ms | 2664 KiB | ||||
21 | Accepted | 2ms | 2740 KiB | ||||
22 | Accepted | 2ms | 2648 KiB | ||||
23 | Accepted | 2ms | 2652 KiB | ||||
24 | Accepted | 3ms | 2936 KiB | ||||
25 | Accepted | 3ms | 2908 KiB | ||||
26 | Accepted | 3ms | 2980 KiB | ||||
27 | Accepted | 3ms | 3164 KiB | ||||
28 | Accepted | 2ms | 3168 KiB | ||||
29 | Accepted | 3ms | 3164 KiB | ||||
30 | Accepted | 2ms | 3248 KiB | ||||
31 | Accepted | 3ms | 3392 KiB | ||||
32 | Accepted | 2ms | 3392 KiB | ||||
33 | Accepted | 2ms | 3396 KiB | ||||
34 | Accepted | 3ms | 3300 KiB | ||||
35 | Accepted | 3ms | 3300 KiB | ||||
36 | Accepted | 3ms | 3448 KiB | ||||
37 | Accepted | 2ms | 3040 KiB | ||||
38 | Accepted | 2ms | 2948 KiB | ||||
39 | Accepted | 3ms | 3404 KiB | ||||
40 | Accepted | 3ms | 3384 KiB | ||||
41 | Accepted | 3ms | 3612 KiB | ||||
42 | Accepted | 3ms | 3600 KiB | ||||
43 | Accepted | 3ms | 3052 KiB | ||||
44 | Accepted | 3ms | 3080 KiB | ||||
45 | Accepted | 3ms | 3728 KiB | ||||
46 | Accepted | 3ms | 4000 KiB | ||||
47 | Accepted | 3ms | 3948 KiB | ||||
48 | Accepted | 3ms | 4008 KiB | ||||
49 | Accepted | 3ms | 4108 KiB | ||||
subtask4 | 16/16 | ||||||
50 | Accepted | 3ms | 2192 KiB | ||||
51 | Accepted | 2ms | 2284 KiB | ||||
52 | Accepted | 3ms | 2496 KiB | ||||
53 | Accepted | 3ms | 2664 KiB | ||||
54 | Accepted | 2ms | 2740 KiB | ||||
55 | Accepted | 2ms | 2648 KiB | ||||
56 | Accepted | 2ms | 2652 KiB | ||||
57 | Accepted | 3ms | 2936 KiB | ||||
58 | Accepted | 3ms | 2908 KiB | ||||
59 | Accepted | 3ms | 2980 KiB | ||||
60 | Accepted | 3ms | 3164 KiB | ||||
61 | Accepted | 2ms | 3168 KiB | ||||
62 | Accepted | 3ms | 3164 KiB | ||||
63 | Accepted | 2ms | 3248 KiB | ||||
64 | Accepted | 3ms | 3392 KiB | ||||
65 | Accepted | 2ms | 3392 KiB | ||||
66 | Accepted | 2ms | 3396 KiB | ||||
67 | Accepted | 3ms | 3300 KiB | ||||
68 | Accepted | 3ms | 3300 KiB | ||||
69 | Accepted | 3ms | 3448 KiB | ||||
70 | Accepted | 3ms | 4076 KiB | ||||
71 | Accepted | 3ms | 4076 KiB | ||||
72 | Accepted | 2ms | 3984 KiB | ||||
73 | Accepted | 3ms | 4076 KiB | ||||
74 | Accepted | 3ms | 4076 KiB | ||||
75 | Accepted | 3ms | 4080 KiB | ||||
76 | Accepted | 3ms | 4080 KiB | ||||
77 | Accepted | 3ms | 3988 KiB | ||||
78 | Accepted | 3ms | 3988 KiB | ||||
79 | Accepted | 3ms | 4096 KiB | ||||
80 | Accepted | 2ms | 3040 KiB | ||||
81 | Accepted | 2ms | 2948 KiB | ||||
82 | Accepted | 3ms | 3404 KiB | ||||
83 | Accepted | 3ms | 3384 KiB | ||||
84 | Accepted | 3ms | 3612 KiB | ||||
85 | Accepted | 3ms | 3600 KiB | ||||
86 | Accepted | 3ms | 3052 KiB | ||||
87 | Accepted | 3ms | 3080 KiB | ||||
88 | Accepted | 3ms | 3728 KiB | ||||
89 | Accepted | 3ms | 4000 KiB | ||||
90 | Accepted | 3ms | 3948 KiB | ||||
91 | Accepted | 3ms | 4008 KiB | ||||
92 | Accepted | 3ms | 4108 KiB | ||||
subtask5 | 60/60 | ||||||
93 | Accepted | 3ms | 2192 KiB | ||||
94 | Accepted | 19ms | 5540 KiB | ||||
95 | Accepted | 2ms | 2284 KiB | ||||
96 | Accepted | 3ms | 2496 KiB | ||||
97 | Accepted | 3ms | 2664 KiB | ||||
98 | Accepted | 2ms | 2740 KiB | ||||
99 | Accepted | 2ms | 2648 KiB | ||||
100 | Accepted | 2ms | 2652 KiB | ||||
101 | Accepted | 3ms | 2936 KiB | ||||
102 | Accepted | 3ms | 2908 KiB | ||||
103 | Accepted | 3ms | 2980 KiB | ||||
104 | Accepted | 3ms | 3164 KiB | ||||
105 | Accepted | 2ms | 3168 KiB | ||||
106 | Accepted | 3ms | 3164 KiB | ||||
107 | Accepted | 2ms | 3248 KiB | ||||
108 | Accepted | 3ms | 3392 KiB | ||||
109 | Accepted | 2ms | 3392 KiB | ||||
110 | Accepted | 2ms | 3396 KiB | ||||
111 | Accepted | 3ms | 3300 KiB | ||||
112 | Accepted | 3ms | 3300 KiB | ||||
113 | Accepted | 3ms | 3448 KiB | ||||
114 | Accepted | 3ms | 4076 KiB | ||||
115 | Accepted | 3ms | 4076 KiB | ||||
116 | Accepted | 2ms | 3984 KiB | ||||
117 | Accepted | 3ms | 4076 KiB | ||||
118 | Accepted | 3ms | 4076 KiB | ||||
119 | Accepted | 3ms | 4080 KiB | ||||
120 | Accepted | 3ms | 4080 KiB | ||||
121 | Accepted | 3ms | 3988 KiB | ||||
122 | Accepted | 3ms | 3988 KiB | ||||
123 | Accepted | 3ms | 4096 KiB | ||||
124 | Accepted | 19ms | 5544 KiB | ||||
125 | Accepted | 19ms | 5628 KiB | ||||
126 | Accepted | 19ms | 5624 KiB | ||||
127 | Accepted | 19ms | 5692 KiB | ||||
128 | Accepted | 19ms | 5544 KiB | ||||
129 | Accepted | 19ms | 5548 KiB | ||||
130 | Accepted | 19ms | 5544 KiB | ||||
131 | Accepted | 19ms | 5688 KiB | ||||
132 | Accepted | 19ms | 5640 KiB | ||||
133 | Accepted | 2ms | 3040 KiB | ||||
134 | Accepted | 2ms | 2948 KiB | ||||
135 | Accepted | 3ms | 3404 KiB | ||||
136 | Accepted | 3ms | 3384 KiB | ||||
137 | Accepted | 3ms | 3612 KiB | ||||
138 | Accepted | 3ms | 3600 KiB | ||||
139 | Accepted | 3ms | 3052 KiB | ||||
140 | Accepted | 3ms | 3080 KiB | ||||
141 | Accepted | 3ms | 3728 KiB | ||||
142 | Accepted | 3ms | 4000 KiB | ||||
143 | Accepted | 3ms | 3948 KiB | ||||
144 | Accepted | 14ms | 5652 KiB | ||||
145 | Accepted | 14ms | 5548 KiB | ||||
146 | Accepted | 14ms | 5772 KiB | ||||
147 | Accepted | 9ms | 5076 KiB | ||||
148 | Accepted | 14ms | 5616 KiB | ||||
149 | Accepted | 14ms | 5516 KiB | ||||
150 | Accepted | 3ms | 4008 KiB | ||||
151 | Accepted | 3ms | 4108 KiB | ||||
152 | Accepted | 14ms | 5660 KiB |