結果

問題 No.919 You Are A Project Manager
ユーザー kotatsugamekotatsugame
提出日時 2019-10-25 23:11:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,385 bytes
コンパイル時間 1,181 ms
コンパイル使用メモリ 87,972 KB
実行使用メモリ 7,884 KB
最終ジャッジ日時 2023-10-11 09:12:56
合計ジャッジ時間 30,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,445 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 46 ms
4,352 KB
testcase_05 AC 54 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 758 ms
4,348 KB
testcase_08 AC 52 ms
4,348 KB
testcase_09 AC 28 ms
4,352 KB
testcase_10 AC 84 ms
4,352 KB
testcase_11 AC 75 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 126 ms
4,352 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 14 ms
4,348 KB
testcase_16 AC 241 ms
4,348 KB
testcase_17 AC 871 ms
4,352 KB
testcase_18 AC 872 ms
4,348 KB
testcase_19 AC 1,444 ms
4,352 KB
testcase_20 TLE -
testcase_21 AC 1,441 ms
4,352 KB
testcase_22 AC 887 ms
4,348 KB
testcase_23 AC 846 ms
4,352 KB
testcase_24 AC 952 ms
4,348 KB
testcase_25 AC 885 ms
4,348 KB
testcase_26 TLE -
testcase_27 AC 2,927 ms
4,352 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N;
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;
		for(int i=0;i*K+K<=N;i++)
		{
			sort(a.begin()+i*K,a.begin()+i*K+K);
			L[i]=a[i*K+(K-1)/2];
		}
		a=A;
		reverse(a.begin(),a.end());
		for(int i=0;i*K+K<=N;i++)
		{
			sort(a.begin()+i*K,a.begin()+i*K+K);
			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);
		}
	}
	{
	priority_queue<int>L;
	priority_queue<int,vector<int>,greater<int> >R;
	for(int i=0;i<N;i++)
	{
		if(L.size()==R.size())
		{
			R.push(A[i]);
			int t=R.top();R.pop();
			L.push(t);
		}
		else
		{
			L.push(A[i]);
			int t=L.top();L.pop();
			R.push(t);
		}
		ans=max(ans,(long)L.top()*(i+1));
	}
	}
	{
	priority_queue<int>L;
	priority_queue<int,vector<int>,greater<int> >R;
	for(int i=0;i<N;i++)
	{
		if(L.size()==R.size())
		{
			R.push(A[N-i-1]);
			int t=R.top();R.pop();
			L.push(t);
		}
		else
		{
			L.push(A[N-i-1]);
			int t=L.top();L.pop();
			R.push(t);
		}
		ans=max(ans,(long)L.top()*(i+1));
	}
	}
	cout<<ans<<endl;
}
0