Submission #1021687

#TimeUsernameProblemLanguageResultExecution timeMemory
1021687guagua0407Hacker (BOI15_hac)C++17
100 / 100
282 ms22356 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int dx[4]={0,0,1,-1}; int dy[4]={1,-1,0,0}; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int inf=2e9+5; int main() {_ int n; cin>>n; vector<int> pre(2*n+1); vector<int> a(n+1); for(int i=1;i<=n;i++){ cin>>a[i]; pre[i]=a[i]+pre[i-1]; } for(int i=n+1;i<=2*n;i++){ pre[i]=pre[i-1]+a[i-n]; } multiset<int> S; vector<int> mn(n+1,inf); int k=(n+1)/2; for(int i=1;i<=2*n;i++){ if(i+k-1<=2*n){ //cout<<"i "<<pre[i+k-1]-pre[i-1]<<'\n'; S.insert(pre[i+k-1]-pre[i-1]); } if(i-1>=k){ //cout<<"e "<<pre[i-1]-pre[i-1-k]<<'\n'; S.erase(S.find(pre[i-1]-pre[i-1-k])); } int node=(i>n?i-n:i); if(!S.empty()) mn[node]=min(mn[node],*S.begin()); } cout<<*max_element(mn.begin()+1,mn.end())<<'\n'; return 0; } //maybe its multiset not set //yeeorz //laborz

Compilation message (stderr)

hac.cpp: In function 'void setIO(std::string)':
hac.cpp:15:12: 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:12: 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...