結果
| 問題 | No.798 コレクション |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-15 22:03:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,033 bytes |
| 記録 | |
| コンパイル時間 | 1,149 ms |
| コンパイル使用メモリ | 123,596 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-01 20:59:13 |
| 合計ジャッジ時間 | 2,061 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;
const long long INF = LLONG_MAX / 2;
int main()
{
int n;
cin >> n;
vector<pair<long long, long long> > v(n);
for(int i=0; i<n; ++i)
cin >> v[i].second >> v[i].first;
sort(v.begin(), v.end());
int m = n - n / 3;
vector<long long> dp(m+1, INF);
dp[0] = 0;
for(int i=n-1; i>=0; --i){
for(int j=m-1; j>=0; --j){
long long cost = v[i].first * j + v[i].second;
dp[j+1] = min(dp[j+1], dp[j] + cost);
}
}
cout << dp[m] << endl;
return 0;
}