結果
問題 | No.798 コレクション |
ユーザー | Tiramister |
提出日時 | 2019-03-15 22:47:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 3,002 bytes |
コンパイル時間 | 1,125 ms |
コンパイル使用メモリ | 114,492 KB |
実行使用メモリ | 34,560 KB |
最終ジャッジ日時 | 2024-07-01 21:21:58 |
合計ジャッジ時間 | 2,242 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,948 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 16 ms
16,896 KB |
testcase_14 | AC | 23 ms
25,344 KB |
testcase_15 | AC | 20 ms
22,016 KB |
testcase_16 | AC | 10 ms
11,904 KB |
testcase_17 | AC | 16 ms
17,408 KB |
testcase_18 | AC | 31 ms
32,640 KB |
testcase_19 | AC | 25 ms
26,624 KB |
testcase_20 | AC | 11 ms
12,288 KB |
testcase_21 | AC | 10 ms
11,008 KB |
testcase_22 | AC | 21 ms
22,144 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 32 ms
34,560 KB |
testcase_25 | AC | 32 ms
34,560 KB |
ソースコード
// IO library#include <cstdio>#include <iomanip>#include <ios>#include <iostream>// algorithm library#include <algorithm>#include <cmath>#include <numeric>#include <random>// contancer library#include <bitset>#include <deque>#include <map>#include <queue>#include <set>#include <string>#include <tuple>#include <vector>using namespace std;using ll = long long;using ld = long double;template <class L, class R>ostream& operator<<(ostream& os, pair<L, R> p);template <class T>ostream& operator<<(ostream& os, vector<T> v) {os << "[";for (auto vv : v) os << vv << ",";return os << "]";}template <class T>ostream& operator<<(ostream& os, set<T> v) {os << "{";for (auto vv : v) os << vv << ",";return os << "}";}template <class L, class R>ostream& operator<<(ostream& os, pair<L, R> p) {return os << "(" << p.first << "," << p.second << ")";}template <class K, class T>ostream& operator<<(ostream& os, map<K, T> v) {os << "{";for (auto vv : v) os << vv << ",";return os << "}";}template <class T>ostream& operator<<(ostream& os, queue<T> q) {os << "[";while (!q.empty()) {os << q.front() << ",";q.pop();}return os << "]";}template <class T>ostream& operator<<(ostream& os, priority_queue<T> q) {os << "{";while (!q.empty()) {os << q.top() << ",";q.pop();}return os << "}";}const ll MOD = 1000000007;// const ll MOD = 998244353;// const int INF = 1 << 25;const ll INF = 1LL << 50;// const ld PI = acos(-1);// const ld EPS = 1e-10;// mt19937 mt(ll(time(0)));template <class T>vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }template <class T, class... Ts>auto Vec(size_t l, Ts... ts) {return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));}template <typename T>inline T sq(T a) { return a * a; }template <typename T>inline T iceil(T n, T d) { return (n + d - 1) / d; }template <typename T>T gcd(T a, T b) {while (b > 0) {a %= b;swap(a, b);}return a;}template <typename T, typename U>T ipow(T b, U n) {T ret = 1;while (n > 0) {if (n & 1) ret *= b;n >>= 1;b *= b;}return ret;}template <typename T, typename U>T mpow(T b, U n) {T ret = 1;while (n > 0) {if (n & 1) ret = ret * b % MOD;n >>= 1;b = b * b % MOD;}return ret;}int main() {int N;cin >> N;int day = N - N / 3;vector<pair<ll, ll>> A(N);for (auto& p : A) {cin >> p.second >> p.first;}sort(A.rbegin(), A.rend());auto dp = Vec<ll>(N + 1, N + 1, INF);dp[0][0] = 0;for (int i = 1; i <= N; ++i) {dp[i][0] = 0;auto p = A[i - 1];for (int d = 1; d <= N; ++d) {dp[i][d] = min(dp[i - 1][d], dp[i - 1][d - 1] + p.second + p.first * (d - 1));}}cout << dp[N][day] << endl;return 0;}