結果

問題 No.919 You Are A Project Manager
ユーザー kotatsugamekotatsugame
提出日時 2019-10-25 23:39:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,752 ms / 3,000 ms
コード長 738 bytes
コンパイル時間 872 ms
コンパイル使用メモリ 78,932 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 01:23:06
合計ジャッジ時間 28,817 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,349 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 23 ms
4,384 KB
testcase_05 AC 26 ms
4,384 KB
testcase_06 AC 3 ms
4,384 KB
testcase_07 AC 321 ms
4,384 KB
testcase_08 AC 29 ms
4,380 KB
testcase_09 AC 17 ms
4,380 KB
testcase_10 AC 43 ms
4,380 KB
testcase_11 AC 42 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 64 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 9 ms
4,380 KB
testcase_16 AC 113 ms
4,380 KB
testcase_17 AC 331 ms
4,380 KB
testcase_18 AC 333 ms
4,384 KB
testcase_19 AC 1,357 ms
4,380 KB
testcase_20 AC 1,435 ms
4,380 KB
testcase_21 AC 1,341 ms
4,380 KB
testcase_22 AC 367 ms
4,380 KB
testcase_23 AC 367 ms
4,384 KB
testcase_24 AC 398 ms
4,380 KB
testcase_25 AC 376 ms
4,380 KB
testcase_26 AC 1,424 ms
4,384 KB
testcase_27 AC 1,151 ms
4,384 KB
testcase_28 AC 1,632 ms
4,384 KB
testcase_29 AC 331 ms
4,384 KB
testcase_30 AC 331 ms
4,384 KB
testcase_31 AC 325 ms
4,380 KB
testcase_32 AC 329 ms
4,380 KB
testcase_33 AC 416 ms
4,384 KB
testcase_34 AC 441 ms
4,380 KB
testcase_35 AC 1,734 ms
4,384 KB
testcase_36 AC 1,725 ms
4,384 KB
testcase_37 AC 1,752 ms
4,384 KB
testcase_38 AC 1,684 ms
4,380 KB
testcase_39 AC 2 ms
4,384 KB
testcase_40 AC 10 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 3 ms
4,384 KB
testcase_43 AC 5 ms
4,380 KB
testcase_44 AC 16 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 12 ms
4,384 KB
testcase_47 AC 372 ms
4,380 KB
testcase_48 AC 363 ms
4,384 KB
testcase_49 AC 423 ms
4,380 KB
testcase_50 AC 376 ms
4,380 KB
testcase_51 AC 327 ms
4,380 KB
testcase_52 AC 203 ms
4,384 KB
testcase_53 AC 316 ms
4,384 KB
testcase_54 AC 10 ms
4,380 KB
testcase_55 AC 2 ms
4,384 KB
testcase_56 AC 1 ms
4,384 KB
testcase_57 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#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;
}
0