結果
| 問題 |
No.472 平均順位
|
| コンテスト | |
| ユーザー |
_3_72_
|
| 提出日時 | 2019-08-28 20:37:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 226 ms / 2,000 ms |
| コード長 | 1,577 bytes |
| コンパイル時間 | 1,523 ms |
| コンパイル使用メモリ | 168,516 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 16:33:03 |
| 合計ジャッジ時間 | 3,016 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
// #define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++)
#define REP(i,n) for(int i = 0;i < (n) ; i++)
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------
// int MOD = 998244353;
int MOD = 1000000007;
int dp[2][15001] = {0};
//----------------------------------------------------------------
signed main(){
ll n,p;
cin >> n >> p;
vector<int> a(n),b(n),c(n);
rep(i,n) cin >> a[i] >> b[i] >> c[i];
for(int i = 0;i < n;i++){
for(int j = 0;j <= p;j++){
dp[(i+1)%2][j] = dp[i%2][j] + a[i];
if(j >= 1) dp[(i+1)%2][j] = min(dp[(i+1)%2][j],dp[i%2][j-1]+b[i]);
if(j >= 2) dp[(i+1)%2][j] = min(dp[(i+1)%2][j],dp[i%2][j-2]+c[i]);
if(j >= 3) dp[(i+1)%2][j] = min(dp[(i+1)%2][j],dp[i%2][j-3]+1);
}
}
// cout << dp[n][p]*1.0/n << endl;
printf("%0.10lf\n",dp[n%2][p]*1.0/n);
return 0;
}
//----------------------------------------------------------------
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://dp.contest.atcoder.jp/tasks/dp_a
// rm -r -f test;oj dl https://abc054.contest.atcoder.jp/tasks/abc054_d
_3_72_