109592024-04-20 19:17:54k_balintMetróutasokcpp17Wrong answer 0/10064ms8296 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1900 KiB
2Wrong answer61ms5324 KiB
subtask20/12
3Wrong answer3ms2404 KiB
4Wrong answer3ms2636 KiB
5Wrong answer3ms2872 KiB
6Wrong answer3ms2820 KiB
7Wrong answer3ms2948 KiB
8Wrong answer3ms3036 KiB
9Wrong answer3ms3172 KiB
10Wrong answer3ms3252 KiB
11Wrong answer3ms3336 KiB
12Wrong answer3ms3552 KiB
13Wrong answer3ms3636 KiB
14Wrong answer3ms3760 KiB
15Wrong answer3ms4000 KiB
16Wrong answer3ms3964 KiB
subtask30/12
17Wrong answer3ms2404 KiB
18Wrong answer3ms2636 KiB
19Wrong answer3ms2872 KiB
20Wrong answer3ms2820 KiB
21Wrong answer3ms2948 KiB
22Wrong answer3ms3036 KiB
23Wrong answer3ms3172 KiB
24Wrong answer3ms3252 KiB
25Wrong answer3ms3336 KiB
26Wrong answer3ms3552 KiB
27Wrong answer3ms3976 KiB
28Wrong answer3ms3972 KiB
29Wrong answer3ms4112 KiB
30Wrong answer3ms4072 KiB
31Wrong answer3ms3980 KiB
32Wrong answer3ms4236 KiB
33Wrong answer3ms4192 KiB
34Wrong answer3ms4196 KiB
35Wrong answer3ms4324 KiB
36Wrong answer3ms4396 KiB
37Wrong answer3ms3636 KiB
38Wrong answer3ms3760 KiB
39Wrong answer3ms4556 KiB
40Wrong answer3ms4556 KiB
41Wrong answer3ms4552 KiB
42Wrong answer3ms4660 KiB
43Wrong answer3ms4000 KiB
44Wrong answer3ms3964 KiB
45Wrong answer3ms4616 KiB
46Wrong answer3ms4752 KiB
47Wrong answer3ms4764 KiB
48Wrong answer3ms5028 KiB
49Wrong answer3ms5104 KiB
subtask40/16
50Wrong answer3ms2404 KiB
51Wrong answer3ms2636 KiB
52Wrong answer3ms2872 KiB
53Wrong answer3ms2820 KiB
54Wrong answer3ms2948 KiB
55Wrong answer3ms3036 KiB
56Wrong answer3ms3172 KiB
57Wrong answer3ms3252 KiB
58Wrong answer3ms3336 KiB
59Wrong answer3ms3552 KiB
60Wrong answer3ms3976 KiB
61Wrong answer3ms3972 KiB
62Wrong answer3ms4112 KiB
63Wrong answer3ms4072 KiB
64Wrong answer3ms3980 KiB
65Wrong answer3ms4236 KiB
66Wrong answer3ms4192 KiB
67Wrong answer3ms4196 KiB
68Wrong answer3ms4324 KiB
69Wrong answer3ms4396 KiB
70Wrong answer3ms5100 KiB
71Wrong answer3ms5104 KiB
72Wrong answer3ms5104 KiB
73Wrong answer3ms5100 KiB
74Wrong answer3ms5100 KiB
75Wrong answer3ms5104 KiB
76Wrong answer3ms5108 KiB
77Wrong answer3ms5056 KiB
78Wrong answer3ms5064 KiB
79Wrong answer3ms5064 KiB
80Wrong answer3ms3636 KiB
81Wrong answer3ms3760 KiB
82Wrong answer3ms4556 KiB
83Wrong answer3ms4556 KiB
84Wrong answer3ms4552 KiB
85Wrong answer3ms4660 KiB
86Wrong answer3ms4000 KiB
87Wrong answer3ms3964 KiB
88Wrong answer3ms4616 KiB
89Wrong answer3ms4752 KiB
90Wrong answer3ms4764 KiB
91Wrong answer3ms5028 KiB
92Wrong answer3ms5104 KiB
subtask50/60
93Wrong answer3ms2404 KiB
94Wrong answer61ms8080 KiB
95Wrong answer3ms2636 KiB
96Wrong answer3ms2872 KiB
97Wrong answer3ms2820 KiB
98Wrong answer3ms2948 KiB
99Wrong answer3ms3036 KiB
100Wrong answer3ms3172 KiB
101Wrong answer3ms3252 KiB
102Wrong answer3ms3336 KiB
103Wrong answer3ms3552 KiB
104Wrong answer3ms3976 KiB
105Wrong answer3ms3972 KiB
106Wrong answer3ms4112 KiB
107Wrong answer3ms4072 KiB
108Wrong answer3ms3980 KiB
109Wrong answer3ms4236 KiB
110Wrong answer3ms4192 KiB
111Wrong answer3ms4196 KiB
112Wrong answer3ms4324 KiB
113Wrong answer3ms4396 KiB
114Wrong answer3ms5100 KiB
115Wrong answer3ms5104 KiB
116Wrong answer3ms5104 KiB
117Wrong answer3ms5100 KiB
118Wrong answer3ms5100 KiB
119Wrong answer3ms5104 KiB
120Wrong answer3ms5108 KiB
121Wrong answer3ms5056 KiB
122Wrong answer3ms5064 KiB
123Wrong answer3ms5064 KiB
124Wrong answer61ms8084 KiB
125Wrong answer61ms8216 KiB
126Wrong answer63ms8260 KiB
127Wrong answer59ms8144 KiB
128Wrong answer64ms8144 KiB
129Wrong answer64ms8148 KiB
130Wrong answer59ms8148 KiB
131Wrong answer59ms8148 KiB
132Wrong answer61ms8296 KiB
133Wrong answer3ms3636 KiB
134Wrong answer3ms3760 KiB
135Wrong answer3ms4556 KiB
136Wrong answer3ms4556 KiB
137Wrong answer3ms4552 KiB
138Wrong answer3ms4660 KiB
139Wrong answer3ms4000 KiB
140Wrong answer3ms3964 KiB
141Wrong answer3ms4616 KiB
142Wrong answer3ms4752 KiB
143Wrong answer3ms4764 KiB
144Wrong answer54ms7924 KiB
145Wrong answer48ms7652 KiB
146Wrong answer57ms8100 KiB
147Wrong answer34ms6824 KiB
148Wrong answer54ms7896 KiB
149Wrong answer52ms7884 KiB
150Wrong answer3ms5028 KiB
151Wrong answer3ms5104 KiB
152Wrong answer52ms8032 KiB