Submission #1251510

#TimeUsernameProblemLanguageResultExecution timeMemory
12515103m17Hacker (BOI15_hac)C++20
0 / 100
0 ms324 KiB
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define fi first #define se second #define int long long const int Nmax = 5e5 + 174; int n , a[Nmax]; int pre[Nmax * 2]; int Ans; multiset <int> S; main(){ cin >> n; for (int i = 1 ; i <= n ; i++) cin >> a[i]; for (int i = 1 ; i <= 2 * n ; i++) pre[i] = pre[i - 1] + a[(i >= n ? i % n + 1 : i)]; int k = n / 2 + (n % 2); for (int i = 1 ; i <= 2 * n ; i++) { S.insert(pre[i + k - 1] - pre[i - 1]); if(i >= k) { Ans = max(Ans , *S.begin()); S.erase(S.find(pre[i] - pre[i - k])); } } cout << Ans; }

Compilation message (stderr)

hac.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...