답안 #93316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93316 2019-01-07T14:48:41 Z luckyboy Hacker (BOI15_hac) C++14
40 / 100
1000 ms 2552 KB
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 500005
#define maxm 1000006
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
int n,a[maxn << 1];
long long ans,sum[maxn << 1];
long long Get(int l,int r)
{
    l %= n;
    r %= n;
    if (l <= r)
    {
        if (l) return sum[r] - sum[l-1];
        return sum[r];
    }
    else
    {
        return sum[r] + sum[n-1] - sum[l-1];
    }
}
int main()
{
    ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
    //freopen(Task".inp", "r",stdin);
    //freopen(Task".out", "w",stdout);
    read(n);
    FOR(i,0,n-1)
    {
        read(a[i]);
        a[i+n] = a[i];
    }
    sum[0] = a[0];
    FOR(i,1,2*n-1) sum[i] = sum[i-1] + a[i];
    FOR(i,0,n-1)
    {
        long long cur = 0;
        FOR(j,i+n/2,i+n-1)
        {
            cur = max(cur,Get(j-n/2+1,j));
        }
        ans = max(ans,sum[n-1] - cur);
    }
    cout << ans;
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 4 ms 376 KB Output is correct
22 Correct 34 ms 504 KB Output is correct
23 Correct 91 ms 504 KB Output is correct
24 Correct 34 ms 480 KB Output is correct
25 Correct 91 ms 504 KB Output is correct
26 Correct 91 ms 528 KB Output is correct
27 Correct 2 ms 392 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 296 KB Output is correct
30 Correct 91 ms 504 KB Output is correct
31 Correct 93 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 92 ms 532 KB Output is correct
4 Execution timed out 1060 ms 2552 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 4 ms 376 KB Output is correct
22 Correct 34 ms 504 KB Output is correct
23 Correct 91 ms 504 KB Output is correct
24 Correct 34 ms 480 KB Output is correct
25 Correct 91 ms 504 KB Output is correct
26 Correct 91 ms 528 KB Output is correct
27 Correct 2 ms 392 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 296 KB Output is correct
30 Correct 91 ms 504 KB Output is correct
31 Correct 93 ms 520 KB Output is correct
32 Correct 2 ms 380 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 92 ms 532 KB Output is correct
35 Execution timed out 1060 ms 2552 KB Time limit exceeded
36 Halted 0 ms 0 KB -