結果

問題 No.472 平均順位
ユーザー Teruya-Himaki
提出日時 2017-09-20 17:50:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,294 bytes
コンパイル時間 1,923 ms
コンパイル使用メモリ 169,864 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-11-08 09:09:16
合計ジャッジ時間 6,306 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other WA * 4 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n,p;cin>>n>>p;
    vector<vector<int> > data(n,vector<int>(3));
    REP(i,n){
        REP(j,3){
            cin>>data[i][j];
        }
    }
    vector<vector<int> > memo(n,vector<int>(p+1));
    vector<vector<bool> > done(n,vector<bool>(p+1));
    function<int (int,int)> func=[=,&func,&done,&memo](int depth,int remain){
        cerr<<"Called:"<<depth<<","<<remain<<endl;
        if(depth==n){
            if(remain==0){
                cerr<<"Returned 0"<<endl;
                return 0;
            }else{
                cerr<<"Returned INF"<<endl;
                return 1<<10;
            }
        }
        if(remain<0){
            cerr<<"Not remained"<<endl;
            return 1<<10;
        }
        if(done[depth][remain]==true){
            return memo[depth][remain];
        }
        done[depth][remain]=true;
        int res=1<<10;
        REP(i,3){
            res=min(res,func(depth+1,remain-i)+data[depth][i]);
        }
        res=min(res,func(depth+1,remain-3)+1);
        return memo[depth][remain]=res;
    };
    cout<<fixed<<setprecision(5)<<(double)func(0,p)/n<<endl;
    return 0;
}

0