Submission #31423

# Submission time Handle Problem Language Result Execution time Memory
31423 2017-08-22T15:02:52 Z imaxblue Hacker (BOI15_hac) C++14
100 / 100
793 ms 25484 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

int n, ans=(1 << 30)+(1 << 29), c;
ll psa[1500005];
multiset<int> s;
int main(){
    scanf("%i", &n);
    fox1(l, n){
        scanf("%i", &psa[l]);
        psa[l+n]=psa[l];
        c+=psa[l];
    }
    fox1(l, n*3){
        psa[l]+=psa[l-1];
    }
    for(int l=n/2; l<=n*2; ++l){
        s.insert(psa[l]-psa[l-n/2]);
        if (s.size()>(n+1)/2) s.erase(s.lb(psa[l-(n+1)/2]-psa[l-n]));
        if (s.size()==(n+1)/2) ans=min(ans, *--s.end());
    }
    cout << c-ans;
    return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:33:28: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%i", &psa[l]);
                            ^
hac.cpp:42:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (s.size()>(n+1)/2) s.erase(s.lb(psa[l-(n+1)/2]-psa[l-n]));
                     ^
hac.cpp:43:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (s.size()==(n+1)/2) ans=min(ans, *--s.end());
                     ^
hac.cpp:31:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i", &n);
                    ^
hac.cpp:33:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i", &psa[l]);
                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 13736 KB Output is correct
2 Correct 0 ms 13736 KB Output is correct
3 Correct 0 ms 13736 KB Output is correct
4 Correct 0 ms 13736 KB Output is correct
5 Correct 0 ms 13736 KB Output is correct
6 Correct 0 ms 13736 KB Output is correct
7 Correct 0 ms 13736 KB Output is correct
8 Correct 0 ms 13736 KB Output is correct
9 Correct 0 ms 13736 KB Output is correct
10 Correct 0 ms 13736 KB Output is correct
11 Correct 0 ms 13736 KB Output is correct
12 Correct 0 ms 13736 KB Output is correct
13 Correct 0 ms 13736 KB Output is correct
14 Correct 0 ms 13736 KB Output is correct
15 Correct 0 ms 13736 KB Output is correct
16 Correct 0 ms 13736 KB Output is correct
17 Correct 0 ms 13736 KB Output is correct
18 Correct 0 ms 13736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 13736 KB Output is correct
2 Correct 0 ms 13736 KB Output is correct
3 Correct 0 ms 13736 KB Output is correct
4 Correct 0 ms 13736 KB Output is correct
5 Correct 0 ms 13736 KB Output is correct
6 Correct 0 ms 13736 KB Output is correct
7 Correct 0 ms 13736 KB Output is correct
8 Correct 0 ms 13736 KB Output is correct
9 Correct 0 ms 13736 KB Output is correct
10 Correct 0 ms 13736 KB Output is correct
11 Correct 0 ms 13736 KB Output is correct
12 Correct 0 ms 13736 KB Output is correct
13 Correct 0 ms 13736 KB Output is correct
14 Correct 0 ms 13736 KB Output is correct
15 Correct 0 ms 13736 KB Output is correct
16 Correct 0 ms 13736 KB Output is correct
17 Correct 0 ms 13736 KB Output is correct
18 Correct 0 ms 13736 KB Output is correct
19 Correct 0 ms 13736 KB Output is correct
20 Correct 0 ms 13736 KB Output is correct
21 Correct 0 ms 13736 KB Output is correct
22 Correct 0 ms 13868 KB Output is correct
23 Correct 3 ms 13868 KB Output is correct
24 Correct 0 ms 13868 KB Output is correct
25 Correct 3 ms 13868 KB Output is correct
26 Correct 3 ms 13868 KB Output is correct
27 Correct 0 ms 13736 KB Output is correct
28 Correct 0 ms 13736 KB Output is correct
29 Correct 0 ms 13736 KB Output is correct
30 Correct 0 ms 13868 KB Output is correct
31 Correct 0 ms 13868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 13736 KB Output is correct
2 Correct 0 ms 13736 KB Output is correct
3 Correct 0 ms 13868 KB Output is correct
4 Correct 56 ms 15584 KB Output is correct
5 Correct 219 ms 18488 KB Output is correct
6 Correct 319 ms 19676 KB Output is correct
7 Correct 366 ms 20732 KB Output is correct
8 Correct 499 ms 25484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 13736 KB Output is correct
2 Correct 0 ms 13736 KB Output is correct
3 Correct 0 ms 13736 KB Output is correct
4 Correct 0 ms 13736 KB Output is correct
5 Correct 0 ms 13736 KB Output is correct
6 Correct 0 ms 13736 KB Output is correct
7 Correct 0 ms 13736 KB Output is correct
8 Correct 0 ms 13736 KB Output is correct
9 Correct 0 ms 13736 KB Output is correct
10 Correct 0 ms 13736 KB Output is correct
11 Correct 0 ms 13736 KB Output is correct
12 Correct 0 ms 13736 KB Output is correct
13 Correct 0 ms 13736 KB Output is correct
14 Correct 0 ms 13736 KB Output is correct
15 Correct 0 ms 13736 KB Output is correct
16 Correct 0 ms 13736 KB Output is correct
17 Correct 0 ms 13736 KB Output is correct
18 Correct 0 ms 13736 KB Output is correct
19 Correct 0 ms 13736 KB Output is correct
20 Correct 0 ms 13736 KB Output is correct
21 Correct 0 ms 13736 KB Output is correct
22 Correct 0 ms 13868 KB Output is correct
23 Correct 3 ms 13868 KB Output is correct
24 Correct 0 ms 13868 KB Output is correct
25 Correct 3 ms 13868 KB Output is correct
26 Correct 3 ms 13868 KB Output is correct
27 Correct 0 ms 13736 KB Output is correct
28 Correct 0 ms 13736 KB Output is correct
29 Correct 0 ms 13736 KB Output is correct
30 Correct 0 ms 13868 KB Output is correct
31 Correct 0 ms 13868 KB Output is correct
32 Correct 0 ms 13736 KB Output is correct
33 Correct 0 ms 13736 KB Output is correct
34 Correct 0 ms 13868 KB Output is correct
35 Correct 56 ms 15584 KB Output is correct
36 Correct 219 ms 18488 KB Output is correct
37 Correct 319 ms 19676 KB Output is correct
38 Correct 366 ms 20732 KB Output is correct
39 Correct 499 ms 25484 KB Output is correct
40 Correct 3 ms 14000 KB Output is correct
41 Correct 9 ms 14264 KB Output is correct
42 Correct 19 ms 14396 KB Output is correct
43 Correct 139 ms 18488 KB Output is correct
44 Correct 563 ms 25484 KB Output is correct
45 Correct 79 ms 16112 KB Output is correct
46 Correct 276 ms 20732 KB Output is correct
47 Correct 793 ms 25484 KB Output is correct
48 Correct 346 ms 25484 KB Output is correct
49 Correct 359 ms 25484 KB Output is correct
50 Correct 339 ms 25484 KB Output is correct