結果
問題 |
No.919 You Are A Project Manager
|
ユーザー |
|
提出日時 | 2019-10-25 23:17:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,422 bytes |
コンパイル時間 | 1,036 ms |
コンパイル使用メモリ | 82,528 KB |
実行使用メモリ | 394,752 KB |
最終ジャッジ日時 | 2024-09-13 08:44:12 |
合計ジャッジ時間 | 40,556 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 WA * 8 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; int N; vector<int>tb[2][10000]; main() { cin>>N; vector<int>A(N); for(int i=0;i<N;i++)cin>>A[i]; long ans=0; for(int K=1;2*K<=N;K++) { vector<long>L(N/K),R(N/K); vector<int>a=A; if(K%2) { for(int i=0;i+K<=N;i+=K)sort(a.begin()+i,a.begin()+i+K); } else { for(int i=0;i+K<=N;i+=K) { int l=0,r=K/2; for(int c=0;c<K;c++) { if(tb[0][K/2][i+l]<tb[0][K/2][i+r]) { a[i+c]=tb[0][K/2][i+l++]; } else { a[i+c]=tb[0][K/2][i+r++]; } } } } for(int i=0;i*K+K<=N;i++) { L[i]=a[i*K+(K-1)/2]; } if(K*2<=N)tb[0][K]=a; a=A; reverse(a.begin(),a.end()); if(K%2) { for(int i=0;i+K<=N;i+=K)sort(a.begin()+i,a.begin()+i+K); } else { for(int i=0;i+K<=N;i+=K) { int l=0,r=K/2; for(int c=0;c<K;c++) { if(tb[1][K/2][i+l]<tb[1][K/2][i+r]) { a[i+c]=tb[1][K/2][i+l++]; } else { a[i+c]=tb[1][K/2][i+r++]; } } } } if(K*2<=N)tb[1][K]=a; for(int i=0;i*K+K<=N;i++) { R[i]=a[i*K+(K-1)/2]; } 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; }