結果
問題 | No.472 平均順位 |
ユーザー |
![]() |
提出日時 | 2018-09-14 16:20:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 299 ms / 2,000 ms |
コード長 | 1,716 bytes |
コンパイル時間 | 897 ms |
コンパイル使用メモリ | 100,432 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 18:15:08 |
合計ジャッジ時間 | 2,539 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <cstdio>#include <iostream>#include <string>#include <vector>#include <sstream>#include <map>#include <set>#include <queue>#include <algorithm>#include <cmath>#include <cstdlib>#include <cstring>#include <typeinfo>#include <numeric>#include <functional>#include <unordered_map>#include <bitset>#include <stack>using namespace std;using ll = long long;using ull = unsigned long long;const ll INF = 1e16;const ll MOD = 1e9 + 7;#define REP(i, n) for(ll i = 0; i < n; i++)int main() {ll n, p;cin >> n >> p;vector<ll> a(n), b(n), c(n);REP(i, n){cin >> a[i] >> b[i] >> c[i];}vector<ll> dp(p + 5, INF);dp[0] = a[0];dp[1] = b[0];dp[2] = c[0];dp[3] = 1;for(ll i = 0; i < n - 1; i++){vector<ll> tmp(p + 5, INF);for(ll j = 0; j <= p; j++){if(j <= p - 3){tmp[j] = min(tmp[j], dp[j] + a[i + 1]);tmp[j + 1] = min(tmp[j + 1], dp[j] + b[i + 1]);tmp[j + 2] = min(tmp[j + 2], dp[j] + c[i + 1]);tmp[j + 3] = min(tmp[j + 3], dp[j] + 1);}else if(j == p - 2){tmp[j] = min(tmp[j], dp[j] + a[i + 1]);tmp[j + 1] = min(tmp[j + 1], dp[j] + b[i + 1]);tmp[j + 2] = min(tmp[j + 2], dp[j] + c[i + 1]);}else if(j == p - 1){tmp[j] = min(tmp[j], dp[j] + a[i + 1]);tmp[j + 1] = min(tmp[j + 1], dp[j] + b[i + 1]);}else{tmp[j] = min(tmp[j], dp[j] + a[i + 1]);}}dp = tmp;}printf("%.7lf\n", (double)dp[p] / (double)n);}