Submission #985890

# Submission time Handle Problem Language Result Execution time Memory
985890 2024-05-19T08:28:36 Z hengliao Hacker (BOI15_hac) C++17
100 / 100
272 ms 34120 KB
#include<bits/stdc++.h>
using namespace std;
 
#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>
typedef long long ll;
 
const ll inf=1e17;
 
void solve(){
	ll n;
    cin>>n;
    vll a(2*n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        a[i+n]=a[i];
    }
    vll val(2*n, inf);
    ll pre=0;
    ll siz=n/2;
    if(n%2==1) siz++;
    for(ll i=0;i<siz;i++){
        pre+=a[i];
    }
    val[0]=pre;
    ll p1=0;
    ll p2=siz;
    for(ll i=1;i<n;i++){
        pre-=a[p1];
        pre+=a[p2];
        p1++;
        p2++;
        val[i]=pre;
    }
    vll ans(n, inf);
    p1=0;
    p2=1;
    multiset<ll> st;
    st.insert(val[0]);
    for(ll i=0;i<2*n;i++){
        while(p1<i-siz+1){
            st.erase(st.find(val[p1]));
            p1++;
        }
        while(p2<=i){
            st.insert(val[p2]);
            p2++;
        }
        ans[i%n]=min(ans[i%n], *st.begin());
    }
    ll o=0;
    for(ll i=0;i<n;i++){
        o=max(o, ans[i]);
    }
    cout<<o<<'\n';
}
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 728 KB Output is correct
26 Correct 2 ms 564 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 852 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 32 ms 5720 KB Output is correct
5 Correct 103 ms 13740 KB Output is correct
6 Correct 119 ms 16988 KB Output is correct
7 Correct 136 ms 20560 KB Output is correct
8 Correct 272 ms 33880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 728 KB Output is correct
26 Correct 2 ms 564 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 852 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 2 ms 600 KB Output is correct
35 Correct 32 ms 5720 KB Output is correct
36 Correct 103 ms 13740 KB Output is correct
37 Correct 119 ms 16988 KB Output is correct
38 Correct 136 ms 20560 KB Output is correct
39 Correct 272 ms 33880 KB Output is correct
40 Correct 4 ms 1116 KB Output is correct
41 Correct 9 ms 1800 KB Output is correct
42 Correct 11 ms 2396 KB Output is correct
43 Correct 94 ms 13644 KB Output is correct
44 Correct 254 ms 33876 KB Output is correct
45 Correct 47 ms 7004 KB Output is correct
46 Correct 147 ms 20556 KB Output is correct
47 Correct 263 ms 33944 KB Output is correct
48 Correct 226 ms 34120 KB Output is correct
49 Correct 221 ms 33340 KB Output is correct
50 Correct 224 ms 33348 KB Output is correct