Submission #497702

#TimeUsernameProblemLanguageResultExecution timeMemory
497702CodurrHacker (BOI15_hac)C++14
20 / 100
331 ms25944 KiB
#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, sum = 0; 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 <= n; i++) v.push_back(v[i]); for (int i = 1; i <= 2 * n; i++) v[i] += v[i - 1]; multiset<int> s; vector<int> ans(n + 1); for (int i = 1; i < n + x; i++) { if (i + x - 1 <= 2 * n) s.insert(v[i + x - 1] - v[i - 1]); if (i >= x) { ans[i % n] = *s.begin(); s.erase(s.find(v[i] - v[i - x])); } } int Ans = -INF; for (int i = 1; i <= n; i++) Ans = max(Ans, ans[i]); cout << Ans; return 0; }

Compilation message (stderr)

hac.cpp: In function 'int main()':
hac.cpp:29:9: warning: unused variable 'sum' [-Wunused-variable]
   29 |  int n, sum = 0;
      |         ^~~
hac.cpp: In function 'void setIO(std::string)':
hac.cpp:15:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   freopen((s + ".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:16:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   freopen((s + ".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...