제출 #1123190

#제출 시각아이디문제언어결과실행 시간메모리
1123190dostsHacker (BOI15_hac)C++20
20 / 100
1096 ms440 KiB
//Dost SEFEROĞLU #include <bits/stdc++.h> #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define all(cont) cont.begin(),cont.end() #define vi vector<int> const int inf = 2e18,MOD = 998244353,N = 2e5+1; int add(int x,int y){ return ((x+y) >= MOD ? x+y-MOD : x+y); } int mult(int x,int y) { return ((x*y)%MOD); } struct Q { stack<pair<pii,pii>> s1,s2; pii merge(pii p1,pii p2) { pii p3 = p1; p3.ff = mult(p3.ff,p2.ff); p3.ss = mult(p3.ss,p2.ff); p3.ss = add(p3.ss,p2.ss); return p3; } void push(pii op) { if (!s1.empty()) s1.push({op,merge(s1.top().ss,op)}); else s1.push({op,op}); } void pop() { if (s2.empty()) { pii cur = {1,0}; while (!s1.empty()) { cur = merge(s1.top().ff,cur); s2.push({s1.top().ff,cur}); s1.pop(); } } s2.pop(); } int eval(int x) { pii pp; if (!s1.empty() && !s2.empty()) pp = merge(s2.top().ss,s1.top().ss); else if (!s1.empty()) pp = s1.top().ss; else if (!s2.empty()) pp = s2.top().ss; else pp = {1,0}; return add(mult(pp.ff,x),pp.ss); } }; void solve() { int n; cin >> n; int ans = 0; vi a(n); for (int i=0;i<n;i++) cin >> a[i]; for (int i=0;i<n;i++) { int cur = inf; int take = (n+1)/2; for (int j = 0;j<=take-1;j++) { int curry = a[i]; for (int jj = 1;jj<=j;jj++) curry+=a[(i-jj+n)%n]; for (int jj = 1;jj<=take-j-1;jj++) curry+=a[(i+jj)%n]; cur = min(cur,curry); } ans = max(ans,cur); } cout << ans << '\n'; } int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #ifdef Dodi freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);/* #else freopen("fcolor.in","r",stdin); freopen("fcolor.out","w",stdout); */ #endif int t = 1; //cin >> t; while (t --> 0) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...