結果
問題 | No.472 平均順位 |
ユーザー |
![]() |
提出日時 | 2018-04-30 12:22:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 334 ms / 2,000 ms |
コード長 | 1,200 bytes |
コンパイル時間 | 2,373 ms |
コンパイル使用メモリ | 167,900 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 23:51:22 |
合計ジャッジ時間 | 3,536 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h>//#define int long longusing namespace std;using LL = long long;using P = pair<int, int>;using Tapris = tuple<int, int, int>;#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)#define REP(i, n) FOR(i, 0, n)#define pb(a) push_back(a)#define all(x) (x).begin(),(x).end()const int INF = (int)1e9;const LL INFL = (LL)1e15;const int MOD = 1e9 + 7;int dy[]={0, 0, 1, -1, 0};int dx[]={1, -1, 0, 0, 0};/*************** using variables ***************/int n, p;int a[5005][4];int dp[15005];/**********************************************/signed main(){cin >> n >> p;REP(i, n) cin >> a[i][0] >> a[i][1] >> a[i][2], a[i][3] = 1;REP(i, n+1) dp[i] = INF;dp[0] = a[0][0];dp[1] = a[0][1];dp[2] = a[0][2];dp[3] = 1;FOR(i, 1, n){int tmp[15005];for(int j = 0; j <= p; j++){int min_num = INF;REP(k, 4){if(j >= k){min_num = min(min_num, a[i][k] + dp[j-k]);}}tmp[j] = min_num;}for(int j = 0; j <= p; j++) dp[j] = tmp[j];}printf("%.9f\n" ,(double)dp[p] / n);}