結果

問題 No.472 平均順位
ユーザー takune1024takune1024
提出日時 2017-12-09 23:39:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 404 ms / 2,000 ms
コード長 940 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 67,256 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 05:21:03
合計ジャッジ時間 3,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 16 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 35 ms
4,376 KB
testcase_12 AC 26 ms
4,376 KB
testcase_13 AC 90 ms
4,376 KB
testcase_14 AC 331 ms
4,376 KB
testcase_15 AC 90 ms
4,376 KB
testcase_16 AC 381 ms
4,376 KB
testcase_17 AC 404 ms
4,376 KB
testcase_18 AC 25 ms
4,380 KB
testcase_19 AC 45 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int dp[2][20000];

int main(){
	int n, p; cin >> n >> p;
	int q[n][4];
	Rep(i, n){
		cin >> q[i][0] >> q[i][1] >> q[i][2];
		q[i][3] = 1;
	}
	Rep(i, 2) Rep(j, 20000) dp[i][j] = inf;
	dp[0][0] = 0;
	Rep(i, n){
		Rep(j, p + 1) Rep(k, 4){
			if(j + k  <= p){
				dp[1][j + k] = min(dp[1][j + k], dp[0][j] + q[i][k]);
			}
		}
		Rep(j, p + 1){
			dp[0][j] = dp[1][j];
			dp[1][j] = inf;
		}
	}
	double ans = (double)dp[0][p] / (double)n;
	printf("%.9f\n", ans);
	return 0;
}
0