結果
| 問題 |
No.919 You Are A Project Manager
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-25 23:20:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,420 bytes |
| コンパイル時間 | 1,044 ms |
| コンパイル使用メモリ | 83,828 KB |
| 実行使用メモリ | 401,696 KB |
| 最終ジャッジ日時 | 2024-09-13 08:49:09 |
| 合計ジャッジ時間 | 14,591 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 19 WA * 1 TLE * 1 -- * 34 |
コンパイルメッセージ
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;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;
}