結果
問題 | No.472 平均順位 |
ユーザー |
|
提出日時 | 2018-11-14 03:10:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 881 bytes |
コンパイル時間 | 805 ms |
コンパイル使用メモリ | 65,728 KB |
実行使用メモリ | 590,336 KB |
最終ジャッジ日時 | 2024-12-24 13:34:23 |
合計ジャッジ時間 | 4,947 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 3 |
other | AC * 11 WA * 2 MLE * 3 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <cstdint>using namespace std;constexpr long long inf = 1e8;int main(){int n, p;cin >> n >> p;vector<vector<int_fast64_t>> rank(n, vector<int_fast64_t>(4, 1));for(auto& x : rank) {cin >> x[0] >> x[1] >> x[2];}vector<vector<int_fast64_t>> dp(n + 1, vector<int_fast64_t>(p + 1, inf));for(auto i = 0; i < 4; ++i) {dp[1][i] = rank[0][i];}for(auto i = 2; i <= n; ++i) {for(auto j = 0; j <= p; ++j) {int_fast64_t temp1 = dp[i - 1][j] + rank[i - 1][0];int_fast64_t temp2 = j > 0 ? dp[i - 1][j - 1] + rank[i - 1][1] : inf;int_fast64_t temp3 = j > 1 ? dp[i - 1][j - 2] + rank[i - 1][2] : inf;int_fast64_t temp4 = j > 2 ? dp[i - 1][j - 3] + rank[i - 1][3] : inf;dp[i][j] = min({temp1, temp2, temp3, temp4});}}cout << 1.0 * dp[n][p] / n << endl;return 0;}