結果

問題 No.472 平均順位
ユーザー kyawashellkyawashell
提出日時 2018-03-28 12:57:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 384 ms / 2,000 ms
コード長 1,010 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 199,220 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 19:23:54
合計ジャッジ時間 4,230 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 33 ms
4,376 KB
testcase_12 AC 24 ms
4,376 KB
testcase_13 AC 84 ms
4,376 KB
testcase_14 AC 314 ms
4,380 KB
testcase_15 AC 86 ms
4,376 KB
testcase_16 AC 362 ms
4,380 KB
testcase_17 AC 384 ms
4,380 KB
testcase_18 AC 24 ms
4,380 KB
testcase_19 AC 42 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF (1e9)

int N,P;
int a[4][5000];
int dp[2][15001];

int main(){
	scanf("%d%d",&N,&P);
	REP(i,N) {
		scanf("%d%d%d",a[0]+i,a[1]+i,a[2]+i);
		a[3][i] = 1;
	}

	REP(j,P+1) {
		dp[1][j] = (j < 4) ? a[j][N - 1] : INF;
	}

	RREP(i,N - 1) {
		REP(j,P+1) {
			int x[4];
			REP(k,4) 
				x[k] = INF;

			REP(k,4) {
				if(j > k - 1) {
					x[k] = dp[1][j - k] + a[k][i];
				}
			}
			int y = INF;
			REP(k,4) {
				if(y > x[k]) 
					y = x[k];
			}
			dp[0][j] = y;
		}
		REP(j,P+1) {
			dp[1][j] = dp[0][j];
		}
	}

	
	printf("%0.10f\n",dp[0][P] / (double)N);
	return 0;
}
0