結果

問題 No.798 コレクション
ユーザー kotatsugamekotatsugame
提出日時 2019-03-15 22:24:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 78,208 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 13:45:39
合計ジャッジ時間 2,297 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 24 ms
4,376 KB
testcase_14 AC 39 ms
4,380 KB
testcase_15 AC 34 ms
4,376 KB
testcase_16 AC 15 ms
4,380 KB
testcase_17 AC 25 ms
4,380 KB
testcase_18 AC 49 ms
4,380 KB
testcase_19 AC 40 ms
4,376 KB
testcase_20 AC 16 ms
4,376 KB
testcase_21 AC 14 ms
4,380 KB
testcase_22 AC 33 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 50 ms
4,376 KB
testcase_25 AC 50 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,a[2000],b[2000];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	int k=0;
	while(k+k/2<n)k++;
	vector<pair<int,int> >x;
	for(int i=0;i<n;i++)x.push_back(make_pair(b[i],a[i]));
	for(int ccc=0;ccc<n-k;ccc++)
	{
		sort(x.begin(),x.end());
		int sum=0;
		vector<pair<int,int> >de;
		for(int i=0;i<x.size();i++)
		{
			int now=x[i].second+x[i].first*(x.size()-i-1);
			de.push_back(make_pair(sum+now,i));
			sum+=x[i].first;
		}
		sort(de.begin(),de.end());
		vector<pair<int,int> >::iterator it=x.begin();
		for(int i=0;i<de[de.size()-1].second;i++)it++;
		x.erase(it);
	}
	long ans=0;
	sort(x.begin(),x.end());
	for(int i=0;i<x.size();i++)ans+=x[x.size()-i-1].second+x[x.size()-i-1].first*i;
	cout<<ans<<endl;
}
0