結果
問題 |
No.472 平均順位
|
ユーザー |
|
提出日時 | 2021-08-23 14:51:42 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 984 bytes |
コンパイル時間 | 3,692 ms |
コンパイル使用メモリ | 144,476 KB |
実行使用メモリ | 296,832 KB |
最終ジャッジ日時 | 2024-11-07 17:16:28 |
合計ジャッジ時間 | 6,232 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 MLE * 2 |
ソースコード
#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; vector<vector<int>> dp(N+1,vector<int>(P+1,INF));// auto chmin = [](int &x, int y) -> int { if(y < x)x = y; return x; }; dp[0][0] = 0; for(int i=0;i<N;++i) { for(int j=0;j<=P;++j) { if(dp[i][j] != INF) { chmin(dp[i+1][j],dp[i][j]+A[i]); if(j+1 <= P)chmin(dp[i+1][j+1], dp[i][j]+B[i]); if(j+2 <= P)chmin(dp[i+1][j+2], dp[i][j]+C[i]); if(j+3 <= P)chmin(dp[i+1][j+3],dp[i][j]+1); } } } std::cout << std::fixed << std::setprecision(15) << (double)dp[N][P]/N << std::endl; }