# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
497696 | 2021-12-23T16:00:32 Z | Codurr | Hacker (BOI15_hac) | C++17 | 1 ms | 320 KB |
#include "bits/stdc++.h" using namespace std; #define int long long //Avoid if time complexity very close to limit #define ll long long #define sz(x) (int)((x).size()) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define f first #define s second void setIO(string s = "") { ios_base::sync_with_stdio(0); cin.tie(0); if (sz(s)) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } } //Imp consts const int MOD = 1e9 + 7; const int MAXN = 2e5 + 1; const int INF = 1e18 + 5; const double pi = 3.14159265358979323846; const double ep = 1e-20; signed main() { setIO(); int n; cin >> n; int x = (n + 1) / 2; vector<int> v(n + 1); for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= x - 1; i++) v.push_back(v[i]); for (int i = 1; i < sz(v); i++) v[i] += v[i - 1]; vector<int> ans(n + 1, INF); for (int i = 1; i <= n; i++) { if (i - x >= 0 && ans[i] > (v[i] - v[i - x])) ans[i] = v[i] - v[i - x]; if (i + x - 1 < (sz(v)) && ans[i] > (v[i + x - 1] - v[i - 1])) ans[i] = v[i + x - 1] - v[i - 1]; } int Ans = -INF; for (int i = 1; i <= n; i++) Ans = max(Ans, ans[i]); cout << Ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 320 KB | Output is correct |
2 | Incorrect | 1 ms | 300 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 320 KB | Output is correct |
2 | Incorrect | 1 ms | 300 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 312 KB | Output is correct |
2 | Incorrect | 1 ms | 208 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 320 KB | Output is correct |
2 | Incorrect | 1 ms | 300 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |