結果
| 問題 | 
                            No.798 コレクション
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Bwambocos
                         | 
                    
| 提出日時 | 2019-03-16 12:25:28 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 799 bytes | 
| コンパイル時間 | 1,871 ms | 
| コンパイル使用メモリ | 179,924 KB | 
| 実行使用メモリ | 34,816 KB | 
| 最終ジャッジ日時 | 2024-07-01 22:26:48 | 
| 合計ジャッジ時間 | 3,213 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 WA * 4 | 
ソースコード
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
const LL inf = 11234567890;
LL N;
std::vector<std::pair<LL, LL>>item;
std::vector<std::vector<LL>>memo;
LL dp(LL i, LL j)
{
	if (i == N)
	{
		if (j == N - N / 3) return 0;
		return inf;
	}
	if (memo[i][j] != -1) return memo[i][j];
	LL res1 = dp(i + 1, j), res2 = dp(i + 1, j + 1) + item[i].second + item[i].first*j;
	return memo[i][j] = std::min(res1, res2);
}
int main()
{
	in >> N;
	std::vector<LL>A(N), B(N);
	rep(i, N) in >> A[i] >> B[i];
	rep(i, N) item.push_back(std::make_pair(B[i], A[i]));
	std::sort(item.begin(), item.end(), std::greater<std::pair<LL, LL>>());
	memo.resize(N);
	rep(i, memo.size()) memo[i].resize(N, -1);
	out << dp(0, 0) << std::endl;
}
            
            
            
        
            
Bwambocos