結果

問題 No.798 コレクション
ユーザー 👑 emthrmemthrm
提出日時 2019-03-15 23:42:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,225 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 132,220 KB
実行使用メモリ 34,540 KB
最終ジャッジ日時 2023-09-14 14:49:12
合計ジャッジ時間 2,516 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 13 ms
16,728 KB
testcase_14 AC 20 ms
25,212 KB
testcase_15 AC 17 ms
22,024 KB
testcase_16 AC 9 ms
11,736 KB
testcase_17 AC 13 ms
17,260 KB
testcase_18 AC 26 ms
32,584 KB
testcase_19 AC 22 ms
26,468 KB
testcase_20 AC 9 ms
12,040 KB
testcase_21 AC 9 ms
10,924 KB
testcase_22 AC 18 ms
22,052 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 28 ms
34,540 KB
testcase_25 AC 28 ms
34,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<pair<int, int> > ba(n); REP(i, n) cin >> ba[i].second >> ba[i].first;
  sort(ALL(ba), greater<pair<int, int> >());
  vector<vector<long long> > dp(n + 1, vector<long long>(n + 1, LINF));
  dp[0][0] = 0;
  FOR(i, 1, n + 1) REP(j, i + 1) {
    dp[i][j] = min((j > 0 ? dp[i - 1][j - 1] : LINF), dp[i - 1][j] + ba[i - 1].second + (long long)ba[i - 1].first * (i - j - 1));
  }
  cout << dp[n][n / 3] << '\n';
  return 0;
}
0