結果
問題 | No.919 You Are A Project Manager |
ユーザー |
|
提出日時 | 2019-10-25 23:39:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,763 ms / 3,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 929 ms |
コンパイル使用メモリ | 78,336 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-27 17:30:14 |
合計ジャッジ時間 | 28,053 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> #include<vector> using namespace std; int N; main() { cin>>N; vector<int>A(N); for(int&a:A)cin>>a; long ans=0; for(int K=1;K<=N;K++) { int t=(K-1)/2; vector<long>L(N/K),R(N/K); vector<int>a=A,b=A; reverse(b.begin(),b.end()); for(int i=0;i+K<=N;i+=K) { nth_element(a.begin()+i,a.begin()+i+t,a.begin()+i+K); L[i/K]=a[i+t]; nth_element(b.begin()+i,b.begin()+i+t,b.begin()+i+K); R[i/K]=b[i+t]; } for(int i=1;i<N/K;i++) { L[i]+=L[i-1]; R[i]+=R[i-1]; } for(int i=1;i<N/K;i++) { L[i]=max(L[i],L[i-1]); R[i]=max(R[i],R[i-1]); } for(int i=-1;i<N/K;i++) { int j=N/K-i-2; ans=max(ans,((i<0?0L:L[i])+(j<0?0L:R[j]))*K); } } cout<<ans<<endl; }