結果
| 問題 | No.472 平均順位 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-23 14:57:28 |
| 言語 | C++17(clang) (17.0.6 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 158 ms / 2,000 ms |
| コード長 | 995 bytes |
| 記録 | |
| コンパイル時間 | 1,613 ms |
| コンパイル使用メモリ | 144,468 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 17:22:32 |
| 合計ジャッジ時間 | 3,107 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <bitset>
#include <map>
#include <set>
#include <queue>
using namespace std;
int main(int argc, char const *argv[])
{
int N,P ; cin >> N >> P;
vector<int> A(N),B(N),C(N);
for(int i=0;i<N;++i)
{
cin >> A[i] >> B[i] >> C[i];
}
const int INF = 1e9;
auto chmin = [](int &x, int y) -> int
{
if(y < x)x = y;
return x;
};
vector<int> dp(P+1,INF);
vector<int> ndp(P+1,INF);
dp[0] = 0;
for(int i=0;i<N;++i)
{
for(int j=P;j>=0;--j)
{
if(dp[j] != INF)
{
chmin(ndp[j],dp[j]+A[i]);
if(j+1 <= P)chmin(ndp[j+1], dp[j]+B[i]);
if(j+2 <= P)chmin(ndp[j+2], dp[j]+C[i]);
if(j+3 <= P)chmin(ndp[j+3],dp[j]+1);
}
}
dp = ndp;
for(auto &x: ndp) x = INF;
}
std::cout << std::fixed << std::setprecision(15) << (double)dp[P]/N << std::endl;
}