結果
| 問題 |
No.798 コレクション
|
| コンテスト | |
| ユーザー |
Jumbo_kpr
|
| 提出日時 | 2019-07-15 04:47:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 1,775 bytes |
| コンパイル時間 | 1,069 ms |
| コンパイル使用メモリ | 104,752 KB |
| 実行使用メモリ | 34,996 KB |
| 最終ジャッジ日時 | 2024-11-25 06:59:09 |
| 合計ジャッジ時間 | 2,366 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define double long double
#define itn int
#define Endl endl
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;
vector<P>v;
int dp[2020][2020];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
itn N; cin >> N;
REP(i, N) {
int a, b; cin >> a >> b;
v.push_back({ b,a });
}
VSORT(v); VREVERSE(v);
dp[0][0] = 0;
REP(i, N) {
REP(j, N) {
if (j == 0) {
dp[i+1][j] = dp[i][j] + v[i].second + v[i].first*(i);
}
else {
dp[i + 1][j] = min(dp[i][j - 1], dp[i][j] + v[i].second + v[i].first*(max((ll)0,i - j)));
}
//pe(i + 1)pe(j)print(dp[i + 1][j]);
}
}
print(dp[N][N / 3]);
}
Jumbo_kpr