제출 #93316

#제출 시각아이디문제언어결과실행 시간메모리
93316luckyboyHacker (BOI15_hac)C++14
40 / 100
1060 ms2552 KiB
/**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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...