10959 | 2024-04-20 19:17:54 | k_balint | Metróutasok | cpp17 | Wrong answer 0/100 | 64ms | 8296 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int c=2e5+5;
int n;
ll arr[c];
ll suf[c];
bool check(ll k){
ll cur=0;
for(int i=1;i<=n;i++){
ll le=(cur+arr[i]-k+1)/2;
if(le>min(arr[i],cur)) return 0;
cur=cur+arr[i]-2*max(0ll,le);
}
return 1;
}
bool jo(ll k){
bool res = check(k);
reverse(arr+1,arr+n+1);
res &= check(k);
reverse(arr+1,arr+n+1);
return res;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
cout << check(576170439-1000) << endl;
ll l=0,r=1e15;
while(l<r-1){
ll mid=l+r>>1;
if(jo(mid)) r=mid;
else l=mid;
}
cout << r << endl;
for(int i=n;i>0;i--) suf[i]=suf[i+1]+arr[i];
ll sum=0;
ll maxi=0;
for(int i=1;i<=n;i++){
if(suf[i+1]>=sum+arr[i]){
sum+=arr[i];
maxi=sum;
}
else{
maxi=max(suf[i+1],maxi);
break;
}
}
cout << maxi << endl;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1900 KiB | ||||
2 | Wrong answer | 61ms | 5324 KiB | ||||
subtask2 | 0/12 | ||||||
3 | Wrong answer | 3ms | 2404 KiB | ||||
4 | Wrong answer | 3ms | 2636 KiB | ||||
5 | Wrong answer | 3ms | 2872 KiB | ||||
6 | Wrong answer | 3ms | 2820 KiB | ||||
7 | Wrong answer | 3ms | 2948 KiB | ||||
8 | Wrong answer | 3ms | 3036 KiB | ||||
9 | Wrong answer | 3ms | 3172 KiB | ||||
10 | Wrong answer | 3ms | 3252 KiB | ||||
11 | Wrong answer | 3ms | 3336 KiB | ||||
12 | Wrong answer | 3ms | 3552 KiB | ||||
13 | Wrong answer | 3ms | 3636 KiB | ||||
14 | Wrong answer | 3ms | 3760 KiB | ||||
15 | Wrong answer | 3ms | 4000 KiB | ||||
16 | Wrong answer | 3ms | 3964 KiB | ||||
subtask3 | 0/12 | ||||||
17 | Wrong answer | 3ms | 2404 KiB | ||||
18 | Wrong answer | 3ms | 2636 KiB | ||||
19 | Wrong answer | 3ms | 2872 KiB | ||||
20 | Wrong answer | 3ms | 2820 KiB | ||||
21 | Wrong answer | 3ms | 2948 KiB | ||||
22 | Wrong answer | 3ms | 3036 KiB | ||||
23 | Wrong answer | 3ms | 3172 KiB | ||||
24 | Wrong answer | 3ms | 3252 KiB | ||||
25 | Wrong answer | 3ms | 3336 KiB | ||||
26 | Wrong answer | 3ms | 3552 KiB | ||||
27 | Wrong answer | 3ms | 3976 KiB | ||||
28 | Wrong answer | 3ms | 3972 KiB | ||||
29 | Wrong answer | 3ms | 4112 KiB | ||||
30 | Wrong answer | 3ms | 4072 KiB | ||||
31 | Wrong answer | 3ms | 3980 KiB | ||||
32 | Wrong answer | 3ms | 4236 KiB | ||||
33 | Wrong answer | 3ms | 4192 KiB | ||||
34 | Wrong answer | 3ms | 4196 KiB | ||||
35 | Wrong answer | 3ms | 4324 KiB | ||||
36 | Wrong answer | 3ms | 4396 KiB | ||||
37 | Wrong answer | 3ms | 3636 KiB | ||||
38 | Wrong answer | 3ms | 3760 KiB | ||||
39 | Wrong answer | 3ms | 4556 KiB | ||||
40 | Wrong answer | 3ms | 4556 KiB | ||||
41 | Wrong answer | 3ms | 4552 KiB | ||||
42 | Wrong answer | 3ms | 4660 KiB | ||||
43 | Wrong answer | 3ms | 4000 KiB | ||||
44 | Wrong answer | 3ms | 3964 KiB | ||||
45 | Wrong answer | 3ms | 4616 KiB | ||||
46 | Wrong answer | 3ms | 4752 KiB | ||||
47 | Wrong answer | 3ms | 4764 KiB | ||||
48 | Wrong answer | 3ms | 5028 KiB | ||||
49 | Wrong answer | 3ms | 5104 KiB | ||||
subtask4 | 0/16 | ||||||
50 | Wrong answer | 3ms | 2404 KiB | ||||
51 | Wrong answer | 3ms | 2636 KiB | ||||
52 | Wrong answer | 3ms | 2872 KiB | ||||
53 | Wrong answer | 3ms | 2820 KiB | ||||
54 | Wrong answer | 3ms | 2948 KiB | ||||
55 | Wrong answer | 3ms | 3036 KiB | ||||
56 | Wrong answer | 3ms | 3172 KiB | ||||
57 | Wrong answer | 3ms | 3252 KiB | ||||
58 | Wrong answer | 3ms | 3336 KiB | ||||
59 | Wrong answer | 3ms | 3552 KiB | ||||
60 | Wrong answer | 3ms | 3976 KiB | ||||
61 | Wrong answer | 3ms | 3972 KiB | ||||
62 | Wrong answer | 3ms | 4112 KiB | ||||
63 | Wrong answer | 3ms | 4072 KiB | ||||
64 | Wrong answer | 3ms | 3980 KiB | ||||
65 | Wrong answer | 3ms | 4236 KiB | ||||
66 | Wrong answer | 3ms | 4192 KiB | ||||
67 | Wrong answer | 3ms | 4196 KiB | ||||
68 | Wrong answer | 3ms | 4324 KiB | ||||
69 | Wrong answer | 3ms | 4396 KiB | ||||
70 | Wrong answer | 3ms | 5100 KiB | ||||
71 | Wrong answer | 3ms | 5104 KiB | ||||
72 | Wrong answer | 3ms | 5104 KiB | ||||
73 | Wrong answer | 3ms | 5100 KiB | ||||
74 | Wrong answer | 3ms | 5100 KiB | ||||
75 | Wrong answer | 3ms | 5104 KiB | ||||
76 | Wrong answer | 3ms | 5108 KiB | ||||
77 | Wrong answer | 3ms | 5056 KiB | ||||
78 | Wrong answer | 3ms | 5064 KiB | ||||
79 | Wrong answer | 3ms | 5064 KiB | ||||
80 | Wrong answer | 3ms | 3636 KiB | ||||
81 | Wrong answer | 3ms | 3760 KiB | ||||
82 | Wrong answer | 3ms | 4556 KiB | ||||
83 | Wrong answer | 3ms | 4556 KiB | ||||
84 | Wrong answer | 3ms | 4552 KiB | ||||
85 | Wrong answer | 3ms | 4660 KiB | ||||
86 | Wrong answer | 3ms | 4000 KiB | ||||
87 | Wrong answer | 3ms | 3964 KiB | ||||
88 | Wrong answer | 3ms | 4616 KiB | ||||
89 | Wrong answer | 3ms | 4752 KiB | ||||
90 | Wrong answer | 3ms | 4764 KiB | ||||
91 | Wrong answer | 3ms | 5028 KiB | ||||
92 | Wrong answer | 3ms | 5104 KiB | ||||
subtask5 | 0/60 | ||||||
93 | Wrong answer | 3ms | 2404 KiB | ||||
94 | Wrong answer | 61ms | 8080 KiB | ||||
95 | Wrong answer | 3ms | 2636 KiB | ||||
96 | Wrong answer | 3ms | 2872 KiB | ||||
97 | Wrong answer | 3ms | 2820 KiB | ||||
98 | Wrong answer | 3ms | 2948 KiB | ||||
99 | Wrong answer | 3ms | 3036 KiB | ||||
100 | Wrong answer | 3ms | 3172 KiB | ||||
101 | Wrong answer | 3ms | 3252 KiB | ||||
102 | Wrong answer | 3ms | 3336 KiB | ||||
103 | Wrong answer | 3ms | 3552 KiB | ||||
104 | Wrong answer | 3ms | 3976 KiB | ||||
105 | Wrong answer | 3ms | 3972 KiB | ||||
106 | Wrong answer | 3ms | 4112 KiB | ||||
107 | Wrong answer | 3ms | 4072 KiB | ||||
108 | Wrong answer | 3ms | 3980 KiB | ||||
109 | Wrong answer | 3ms | 4236 KiB | ||||
110 | Wrong answer | 3ms | 4192 KiB | ||||
111 | Wrong answer | 3ms | 4196 KiB | ||||
112 | Wrong answer | 3ms | 4324 KiB | ||||
113 | Wrong answer | 3ms | 4396 KiB | ||||
114 | Wrong answer | 3ms | 5100 KiB | ||||
115 | Wrong answer | 3ms | 5104 KiB | ||||
116 | Wrong answer | 3ms | 5104 KiB | ||||
117 | Wrong answer | 3ms | 5100 KiB | ||||
118 | Wrong answer | 3ms | 5100 KiB | ||||
119 | Wrong answer | 3ms | 5104 KiB | ||||
120 | Wrong answer | 3ms | 5108 KiB | ||||
121 | Wrong answer | 3ms | 5056 KiB | ||||
122 | Wrong answer | 3ms | 5064 KiB | ||||
123 | Wrong answer | 3ms | 5064 KiB | ||||
124 | Wrong answer | 61ms | 8084 KiB | ||||
125 | Wrong answer | 61ms | 8216 KiB | ||||
126 | Wrong answer | 63ms | 8260 KiB | ||||
127 | Wrong answer | 59ms | 8144 KiB | ||||
128 | Wrong answer | 64ms | 8144 KiB | ||||
129 | Wrong answer | 64ms | 8148 KiB | ||||
130 | Wrong answer | 59ms | 8148 KiB | ||||
131 | Wrong answer | 59ms | 8148 KiB | ||||
132 | Wrong answer | 61ms | 8296 KiB | ||||
133 | Wrong answer | 3ms | 3636 KiB | ||||
134 | Wrong answer | 3ms | 3760 KiB | ||||
135 | Wrong answer | 3ms | 4556 KiB | ||||
136 | Wrong answer | 3ms | 4556 KiB | ||||
137 | Wrong answer | 3ms | 4552 KiB | ||||
138 | Wrong answer | 3ms | 4660 KiB | ||||
139 | Wrong answer | 3ms | 4000 KiB | ||||
140 | Wrong answer | 3ms | 3964 KiB | ||||
141 | Wrong answer | 3ms | 4616 KiB | ||||
142 | Wrong answer | 3ms | 4752 KiB | ||||
143 | Wrong answer | 3ms | 4764 KiB | ||||
144 | Wrong answer | 54ms | 7924 KiB | ||||
145 | Wrong answer | 48ms | 7652 KiB | ||||
146 | Wrong answer | 57ms | 8100 KiB | ||||
147 | Wrong answer | 34ms | 6824 KiB | ||||
148 | Wrong answer | 54ms | 7896 KiB | ||||
149 | Wrong answer | 52ms | 7884 KiB | ||||
150 | Wrong answer | 3ms | 5028 KiB | ||||
151 | Wrong answer | 3ms | 5104 KiB | ||||
152 | Wrong answer | 52ms | 8032 KiB |