Submission #65029251


Source Code Expand

#include <bits/stdc++.h>

using namespace std;
#define fastio ios::sync_with_stdio(false), cin.tie(NULL)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;

struct st{
    ll s, c, p;
};

vector<st> arr;
ll n, x;
double dp[5010][1 << 8];

double func(ll i, ll j){
    if(dp[i][j] != -1) return dp[i][j];
    double ans = 0;
    for(int nxt = 0; nxt < n; nxt++){
        if(j & (1 << nxt)) continue;
        if(i + arr[nxt].c > x) continue;
        double suc = func(i + arr[nxt].c, j | (1 << nxt));
        double fail = func(i + arr[nxt].c, j);
        double tmp = (suc + arr[nxt].s) * arr[nxt].p / 100 + fail * (100 - arr[nxt].p) / 100;
        ans = max(ans, tmp);
    }
    return dp[i][j] = ans;
}
int main() {
    fastio;
    cin >> n >> x;
    arr.resize(n);
    for(auto &i : arr)
        cin >> i.s >> i.c >> i.p;

    sort(arr.begin(), arr.end(), [](st a, st b){
        if(a.s * a.p == b.s * b.p)
            return a.c < b.c;
        return a.s * a.p > b.s * b.p;
    });

    for(int i = 0; i < (1 << n); i++){
        for(int j = 0; j <= x; j++){
            dp[j][i] = -1;
        }
    }

    func(0, 0);

    cout << fixed << setprecision(10) << dp[0][0] << endl;
    return 0;
}

Submission Info

Submission Time
Task E - Payment Required
User now_cow
Language C++ 23 (Clang 16.0.6)
Score 450
Code Size 1318 Byte
Status AC
Exec Time 109 ms
Memory 14276 KiB

Compile Error

./Main.cpp:9:10: warning: unused variable 'mod' [-Wunused-const-variable]
const ll mod = 1e9 + 7;
         ^
1 warning generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 4
AC × 43
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt, 02_random_26.txt, 02_random_27.txt, 02_random_28.txt, 02_random_29.txt, 02_random_30.txt, 02_random_31.txt, 02_random_32.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3700 KiB
00_sample_01.txt AC 1 ms 3708 KiB
00_sample_02.txt AC 1 ms 3856 KiB
00_sample_03.txt AC 2 ms 3848 KiB
01_handmade_00.txt AC 1 ms 3736 KiB
01_handmade_01.txt AC 1 ms 3808 KiB
01_handmade_02.txt AC 5 ms 14252 KiB
01_handmade_03.txt AC 5 ms 14216 KiB
01_handmade_04.txt AC 68 ms 14160 KiB
01_handmade_05.txt AC 66 ms 14248 KiB
02_random_00.txt AC 2 ms 6052 KiB
02_random_01.txt AC 1 ms 4156 KiB
02_random_02.txt AC 2 ms 5784 KiB
02_random_03.txt AC 4 ms 11764 KiB
02_random_04.txt AC 5 ms 12160 KiB
02_random_05.txt AC 8 ms 14260 KiB
02_random_06.txt AC 7 ms 14276 KiB
02_random_07.txt AC 4 ms 11004 KiB
02_random_08.txt AC 9 ms 12780 KiB
02_random_09.txt AC 5 ms 13668 KiB
02_random_10.txt AC 13 ms 13744 KiB
02_random_11.txt AC 5 ms 13740 KiB
02_random_12.txt AC 17 ms 13716 KiB
02_random_13.txt AC 5 ms 13752 KiB
02_random_14.txt AC 13 ms 13700 KiB
02_random_15.txt AC 5 ms 13628 KiB
02_random_16.txt AC 12 ms 13696 KiB
02_random_17.txt AC 5 ms 13608 KiB
02_random_18.txt AC 12 ms 13696 KiB
02_random_19.txt AC 5 ms 13884 KiB
02_random_20.txt AC 38 ms 13948 KiB
02_random_21.txt AC 5 ms 13796 KiB
02_random_22.txt AC 12 ms 13724 KiB
02_random_23.txt AC 5 ms 13684 KiB
02_random_24.txt AC 12 ms 13796 KiB
02_random_25.txt AC 6 ms 13948 KiB
02_random_26.txt AC 109 ms 14132 KiB
02_random_27.txt AC 5 ms 14272 KiB
02_random_28.txt AC 69 ms 14276 KiB
02_random_29.txt AC 5 ms 13896 KiB
02_random_30.txt AC 64 ms 14268 KiB
02_random_31.txt AC 5 ms 13904 KiB
02_random_32.txt AC 69 ms 14272 KiB