답안 #785069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785069 2023-07-17T04:02:50 Z Hanksburger Hacker (BOI15_hac) C++17
100 / 100
145 ms 10756 KB
#include <bits/stdc++.h>
using namespace std;
int seg[2000005], a[500005], b[500005], n, mx;
void build(int i, int l, int r)
{
    if (l==r)
    {
        if (l>n/2)
            seg[i]=b[n-1]-b[l-1]+b[l-n/2-1];
        else
            seg[i]=b[l+(n-1)/2]-b[l-1];
        return;
    }
    int m=(l+r)/2;
    build(i*2, l, m);
    build(i*2+1, m+1, r);
    seg[i]=min(seg[i*2], seg[i*2+1]);
}
int qry(int i, int l, int r, int ql, int qr)
{
    if (ql<=l && r<=qr)
        return seg[i];
    int m=(l+r)/2, res=1e9;
    if (l<=qr && ql<=m)
        res=min(res, qry(i*2, l, m, ql, qr));
    if (m<qr && ql<=r)
        res=min(res, qry(i*2+1, m+1, r, ql, qr));
    return res;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a[0];
    b[0]=a[0];
    for (int i=1; i<n; i++)
    {
        cin >> a[i];
        b[i]=b[i-1]+a[i];
    }
    build(1, 0, n-1);
    for (int i=0; i<n; i++)
    {
        if (i>n/2)
            mx=max(mx, min(qry(1, 0, n-1, i, n-1), qry(1, 0, n-1, 0, i-n/2-1)));
        else
            mx=max(mx, qry(1, 0, n-1, i, i+(n-1)/2));
    }
    cout << mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 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 340 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 21 ms 2348 KB Output is correct
5 Correct 53 ms 4704 KB Output is correct
6 Correct 68 ms 5424 KB Output is correct
7 Correct 96 ms 8220 KB Output is correct
8 Correct 145 ms 10508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 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 340 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 472 KB Output is correct
35 Correct 21 ms 2348 KB Output is correct
36 Correct 53 ms 4704 KB Output is correct
37 Correct 68 ms 5424 KB Output is correct
38 Correct 96 ms 8220 KB Output is correct
39 Correct 145 ms 10508 KB Output is correct
40 Correct 3 ms 468 KB Output is correct
41 Correct 6 ms 832 KB Output is correct
42 Correct 9 ms 852 KB Output is correct
43 Correct 54 ms 4796 KB Output is correct
44 Correct 141 ms 10464 KB Output is correct
45 Correct 28 ms 2388 KB Output is correct
46 Correct 83 ms 8076 KB Output is correct
47 Correct 142 ms 10500 KB Output is correct
48 Correct 140 ms 10756 KB Output is correct
49 Correct 137 ms 9912 KB Output is correct
50 Correct 138 ms 9804 KB Output is correct