Submission #65030801
Source Code Expand
Copy
// Original Python code:// def li():// return list(map(int, input().split()))// import sys// sys.setrecursionlimit(10**6)// import pypyjit// pypyjit.set_param('max_unroll_recursion=-1')//// n,x=li()// scp=[li() for _ in range(n)]// dp={}// rr=[0]*(1<<n)// for i in range(1<<n):// tmp=0// for j in range(n):// if (i>>j)&1:// tmp+=scp[j][0]// rr[i]=tmp// def solve(state,val):// if (state,val) in dp:return dp[(state,val)]// res=rr[state]
// Original Python code:
// def li():
// return list(map(int, input().split()))
// import sys
// sys.setrecursionlimit(10**6)
// import pypyjit
// pypyjit.set_param('max_unroll_recursion=-1')
//
// n,x=li()
// scp=[li() for _ in range(n)]
// dp={}
// rr=[0]*(1<<n)
// for i in range(1<<n):
// tmp=0
// for j in range(n):
// if (i>>j)&1:
// tmp+=scp[j][0]
// rr[i]=tmp
// def solve(state,val):
// if (state,val) in dp:return dp[(state,val)]
// res=rr[state]
//
// for i in range(n):
// if (state>>i)&1:
// continue
// if val-scp[i][1]<0:continue
// nxt=state+(1<<i)
// tmp=(scp[i][2]/100)*solve(nxt,val-scp[i][1])+(1-scp[i][2]/100)*solve(state,val-scp[i][1])
// res=max(res,tmp)
// dp[(state,val)]=res
// return res
// print(solve(0,x))
#include <bits/stdc++.h>
using namespace std;
int n, x;
vector<array<int, 3>> scp;
vector<int> rr;
map<pair<int, int>, double> dp;
double solve(int state, int val) {
pair<int, int> key = {state, val};
if (dp.count(key)) return dp[key];
double res = rr[state];
for (int i = 0; i < n; ++i) {
if ((state >> i) & 1) continue;
if (val - scp[i][1] < 0) continue;
int nxt = state | (1 << i);
double tmp = (scp[i][2] / 100.0) * solve(nxt, val - scp[i][1])
+ (1.0 - scp[i][2] / 100.0) * solve(state, val - scp[i][1]);
res = max(res, tmp);
}
dp[key] = res;
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> x;
scp.resize(n);
for (int i = 0; i < n; ++i) {
cin >> scp[i][0] >> scp[i][1] >> scp[i][2];
}
int size = 1 << n;
rr.resize(size, 0);
for (int i = 0; i < size; ++i) {
int tmp = 0;
for (int j = 0; j < n; ++j) {
if ((i >> j) & 1) {
tmp += scp[j][0];
}
}
rr[i] = tmp;
}
cout << fixed << setprecision(10) << solve(0, x) << "\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Payment Required |
| User | juntenbanana |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 2126 Byte |
| Status | TLE |
| Exec Time | 2214 ms |
| Memory | 60432 KB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 450 | ||||||
| Status |
|
|
| 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 | 3756 KB |
| 00_sample_01.txt | AC | 1 ms | 3924 KB |
| 00_sample_02.txt | AC | 1 ms | 3844 KB |
| 00_sample_03.txt | AC | 10 ms | 4336 KB |
| 01_handmade_00.txt | AC | 1 ms | 3676 KB |
| 01_handmade_01.txt | AC | 1 ms | 3720 KB |
| 01_handmade_02.txt | AC | 2 ms | 5064 KB |
| 01_handmade_03.txt | AC | 2 ms | 4924 KB |
| 01_handmade_04.txt | TLE | 2214 ms | 59408 KB |
| 01_handmade_05.txt | TLE | 2211 ms | 59368 KB |
| 02_random_00.txt | AC | 1 ms | 3684 KB |
| 02_random_01.txt | AC | 1 ms | 3824 KB |
| 02_random_02.txt | AC | 1 ms | 3816 KB |
| 02_random_03.txt | AC | 1 ms | 3812 KB |
| 02_random_04.txt | AC | 1 ms | 3748 KB |
| 02_random_05.txt | AC | 67 ms | 9364 KB |
| 02_random_06.txt | AC | 22 ms | 6932 KB |
| 02_random_07.txt | AC | 5 ms | 5120 KB |
| 02_random_08.txt | AC | 156 ms | 12852 KB |
| 02_random_09.txt | AC | 1 ms | 3780 KB |
| 02_random_10.txt | AC | 1 ms | 3816 KB |
| 02_random_11.txt | AC | 1 ms | 4108 KB |
| 02_random_12.txt | AC | 263 ms | 11696 KB |
| 02_random_13.txt | AC | 1 ms | 3824 KB |
| 02_random_14.txt | AC | 1 ms | 3748 KB |
| 02_random_15.txt | AC | 1 ms | 3756 KB |
| 02_random_16.txt | AC | 1 ms | 3816 KB |
| 02_random_17.txt | AC | 1 ms | 3764 KB |
| 02_random_18.txt | AC | 1 ms | 3816 KB |
| 02_random_19.txt | AC | 4 ms | 4768 KB |
| 02_random_20.txt | AC | 1685 ms | 43952 KB |
| 02_random_21.txt | AC | 1 ms | 3812 KB |
| 02_random_22.txt | AC | 1 ms | 3756 KB |
| 02_random_23.txt | AC | 1 ms | 3760 KB |
| 02_random_24.txt | AC | 1 ms | 3972 KB |
| 02_random_25.txt | AC | 6 ms | 5288 KB |
| 02_random_26.txt | TLE | 2211 ms | 59108 KB |
| 02_random_27.txt | AC | 7 ms | 5624 KB |
| 02_random_28.txt | TLE | 2211 ms | 59440 KB |
| 02_random_29.txt | AC | 4 ms | 4712 KB |
| 02_random_30.txt | TLE | 2211 ms | 60432 KB |
| 02_random_31.txt | AC | 7 ms | 5312 KB |
| 02_random_32.txt | TLE | 2210 ms | 57480 KB |