結果
| 問題 | 
                            No.798 コレクション
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-03-15 22:30:16 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 10 ms / 2,000 ms | 
| コード長 | 558 bytes | 
| コンパイル時間 | 910 ms | 
| コンパイル使用メモリ | 77,648 KB | 
| 実行使用メモリ | 14,336 KB | 
| 最終ジャッジ日時 | 2024-07-01 21:09:51 | 
| 合計ジャッジ時間 | 1,724 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 | 
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
            
            ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
vector<pair<int,int> >a;
long dp[2001][700];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int u,v;cin>>u>>v;
		a.push_back(make_pair(v,u));
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	for(int i=0;i<=n;i++)for(int j=0;j<700;j++)dp[i][j]=9e18;
	dp[0][0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=n/3;j++)
		{
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+a[i].second+1L*a[i].first*(i-j));
		}
	}
	cout<<dp[n][n/3]<<endl;
}