結果
問題 | No.472 平均順位 |
ユーザー |
|
提出日時 | 2019-01-16 21:53:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 268 ms / 2,000 ms |
コード長 | 1,295 bytes |
コンパイル時間 | 584 ms |
コンパイル使用メモリ | 78,116 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 17:20:44 |
合計ジャッジ時間 | 2,348 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <iostream>#include <cmath>#include <string>#include <algorithm>#include <set>#include <vector>#include <map>#include <list>#include <stack>#include <cstdio>#include <cstring>#include <cstdlib>#include <queue>#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) (a<b ? a=b : 0)#define chmin(a, b) (a>b ? a=b : 0)#define INF 1000000000000000000#define MOD 1000000007LL#define MAX 101010using namespace std;typedef long long ll;typedef pair<ll, ll> P;typedef map<ll, ll> 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<N; i++) {cin >> a[i] >> b[i] >> c[i];}for(i=1; i<=P; i++)dp[i]=INF;dp[0]=0;for(i=0; i<N; i++) {for(j=P; j>=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);}