結果

問題 No.472 平均順位
ユーザー Teruya-HimakiTeruya-Himaki
提出日時 2017-09-20 17:50:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,294 bytes
コンパイル時間 1,346 ms
コンパイル使用メモリ 170,016 KB
実行使用メモリ 11,932 KB
最終ジャッジ日時 2024-04-25 21:14:14
合計ジャッジ時間 5,588 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,808 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

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