Submission #581022

# Submission time Handle Problem Language Result Execution time Memory
581022 2022-06-22T08:26:05 Z ktkerem Hacker (BOI15_hac) C++17
100 / 100
343 ms 22240 KB
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
/*#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
template<class T>
using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
/**/
//typedef int ll;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 vll;
typedef unsigned __int128 uvll;
ll _i=0;
#define ffn(x) _i=x
#define llll std::pair<ll , ll>
#define stitr set<ll>::iterator
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define halo cout << "hello\n"
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e18 + 7; 
const ll ous = 3e5;
const ll dx[4] = {1 , 0 , 0 , -1} , dy[4] = {0,1,-1,0};
void solve(){
    ll n;std::cin >> n;
    ll ar[n];
    fora(i, n){
        std::cin >> ar[i];
    }
    ll p = 0;
    std::vector<ll> ns;
    std::multiset<ll> st;
    for(ll i = 0;n/2 + (n & 1) > i;i++){
        p+=ar[i];
    }
    ns.pb(p);
    for(ll i = n/2 + (n & 1);n + n/2 + (n & 1) - 1 > i;i++){
        p-= ar[(i-(n/2 + (n & 1))) % n];
        p+= ar[i % n];
        ns.pb(p); 
    }
    for(ll i = 0;n/2 + (n & 1) > i;i++){
        st.insert(ns[i]);
    }
    ll ans = *st.begin();
    for(ll i = n/2 + (n & 1);n + n/2 + (n & 1) - 1 > i;i++){
        st.erase(st.find(ns[(i-(n/2 + (n & 1))) % n]));
        st.insert(ns[i % n]);
        ans = std::max(ans , *st.begin());
    }
    std::cout << ans << "\n";
    return;/**/
}
signed main(){
    std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
    ll t=1;
    //std::cin >> t;
    ll o = 1;
    while(t--){ 
        //cout << "Case " << o++ << ":\n";
        solve();
    }
    return 0; 
}

Compilation message

hac.cpp:12:1: warning: "/*" within comment [-Wcomment]
   12 | /**/
      |  
hac.cpp: In function 'int main()':
hac.cpp:66:8: warning: unused variable 'o' [-Wunused-variable]
   66 |     ll o = 1;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 3 ms 468 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 0 ms 320 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 30 ms 3792 KB Output is correct
5 Correct 88 ms 8900 KB Output is correct
6 Correct 139 ms 11180 KB Output is correct
7 Correct 135 ms 13344 KB Output is correct
8 Correct 343 ms 22104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 3 ms 468 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 0 ms 320 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 30 ms 3792 KB Output is correct
36 Correct 88 ms 8900 KB Output is correct
37 Correct 139 ms 11180 KB Output is correct
38 Correct 135 ms 13344 KB Output is correct
39 Correct 343 ms 22104 KB Output is correct
40 Correct 4 ms 724 KB Output is correct
41 Correct 8 ms 1112 KB Output is correct
42 Correct 14 ms 1624 KB Output is correct
43 Correct 96 ms 8892 KB Output is correct
44 Correct 258 ms 21976 KB Output is correct
45 Correct 42 ms 4528 KB Output is correct
46 Correct 137 ms 13356 KB Output is correct
47 Correct 294 ms 21976 KB Output is correct
48 Correct 244 ms 22240 KB Output is correct
49 Correct 214 ms 21344 KB Output is correct
50 Correct 207 ms 21372 KB Output is correct