#include #include #include #include #include #include #include #include #include #include #include #include #include #define mkp make_pair #define fi first #define se second #define pt(num) cout << num << "\n" #define max(a, b) ((a)>(b) ? (a):(b)) #define min(a, b) ((a)<(b) ? (a):(b)) #define chmax(a, b) (ab ? a=b : 0) #define INF 1000000000000000000 #define MOD 1000000007LL #define MAX 101010 using namespace std; typedef long long ll; typedef pair P; typedef map Map; int main(void) { ll N, P; cin >> N >> P; ll i, j; ll a[N+5], b[N+5], c[N+5]; ll dp[P+5]; for(i=0; i> a[i] >> b[i] >> c[i]; } for(i=1; i<=P; i++) dp[i]=INF; dp[0]=0; for(i=0; i=0; j--) { dp[j]=dp[j]+a[i]; if(j>=1 && dp[j-1]!=-1) chmin(dp[j], dp[j-1]+b[i]); if(j>=2 && dp[j-2]!=-1) chmin(dp[j], dp[j-2]+c[i]); if(j>=3 && dp[j-3]!=-1) chmin(dp[j], dp[j-3]+1); } } printf("%.10f\n", (double)(dp[P])/(double)N); }