結果
| 問題 |
No.798 コレクション
|
| コンテスト | |
| ユーザー |
Bwambocos
|
| 提出日時 | 2019-03-16 12:27:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 808 bytes |
| コンパイル時間 | 1,931 ms |
| コンパイル使用メモリ | 179,960 KB |
| 実行使用メモリ | 34,688 KB |
| 最終ジャッジ日時 | 2024-07-01 22:26:34 |
| 合計ジャッジ時間 | 3,344 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 23 |
コンパイルメッセージ
main.cpp:7:16: warning: integer constant is so large that it is unsigned
7 | const LL inf = 11234567890123456789;
| ^~~~~~~~~~~~~~~~~~~~
ソースコード
#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 = 11234567890123456789;
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