結果

問題 No.472 平均順位
ユーザー motakine
提出日時 2020-05-13 11:54:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 1,956 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 172,828 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 15:31:42
合計ジャッジ時間 3,687 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using mat = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }
template<class T> struct edge { int to; T cost;};
int main() {
int N,M; cin >>N >>M;
vector<int> a(N),b(N),c(N); rep(i, N) cin >>a[i] >>b[i] >>c[i];
vector<vector<int>> dp(2, vector<int>(M+1, inf));
dp[0][0] = 0;
for (int i=0; i<N; i++){
for (int j=0; j<=M; j++){
chmin(dp[1][j], dp[0][j] + a[i]);
if (j+1 <= M) chmin(dp[1][j+1], dp[0][j] + b[i]);
if (j+2 <= M) chmin(dp[1][j+2], dp[0][j] + c[i]);
if (j+3 <= M) chmin(dp[1][j+3], dp[0][j] + 1);
}
swap(dp[0], dp[1]);
for (int j=0; j<=M; j++) dp[1][j] = inf;
}
double res = dp[0][M] / (double)N;
cout <<res <<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0