Submission #1589985
Source Code Expand
#include<iostream> #include<algorithm> #include<functional> #include<string> #include<vector> #include<map> #include<set> #include<tuple> #include<stack> #include<queue> #include<deque> #include<sstream> #include<stdio.h> #include<math.h> #include<stdlib.h> #include<bitset> #include<time.h> #include<cstdlib> #include<cassert> #define ll long long #define fi first #define se second using namespace std; int n,a,b; vector<pair<int,pair<int,int> > > v; const int inf=999999999; int dp[41][500][500]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<<fixed; #ifdef LOCAL_DEFINE freopen("in", "r", stdin); freopen("out","w",stdout); #endif cin>>n>>a>>b; for(int i=0;i<n;i++){ int e,f,g;cin>>e>>f>>g; v.push_back(make_pair(e,make_pair(f,g))); } for(int i=0;i<41;i++)for(int j=0;j<500;j++)for(int k=0;k<500;k++)dp[i][j][k]=inf; dp[0][0][0]=0; for(int i=0;i<n;i++){ for(int j=0;j<500;j++){ for(int k=0;k<500;k++){ dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]); dp[i+1][j+v[i].fi][k+v[i].se.fi]=min(dp[i+1][j+v[i].fi][k+v[i].se.fi],dp[i][j][k]+v[i].se.se); } } } int ans=inf; for(int i=1;i<500;i++)for(int j=1;j<500;j++){ if(i*b==j*a)ans=min(ans,dp[n][i][j]); } cout<<(ans==inf?-1:ans)<<"\n"; #ifdef LOCAL_DEFINE cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Mixing Experiment |
User | aim_cpo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1498 Byte |
Status | RE |
Exec Time | 140 ms |
Memory | 40320 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 16 ms | 40320 KB |
sample_02.txt | AC | 15 ms | 40320 KB |
subtask_1_01.txt | AC | 17 ms | 40320 KB |
subtask_1_02.txt | AC | 15 ms | 40320 KB |
subtask_1_03.txt | AC | 17 ms | 40320 KB |
subtask_1_04.txt | AC | 21 ms | 40320 KB |
subtask_1_05.txt | AC | 23 ms | 40320 KB |
subtask_1_06.txt | AC | 27 ms | 40320 KB |
subtask_1_07.txt | AC | 29 ms | 40320 KB |
subtask_1_08.txt | AC | 30 ms | 40320 KB |
subtask_1_09.txt | AC | 34 ms | 40320 KB |
subtask_1_10.txt | AC | 37 ms | 40320 KB |
subtask_1_11.txt | AC | 41 ms | 40320 KB |
subtask_1_12.txt | RE | 137 ms | 40320 KB |
subtask_1_13.txt | RE | 137 ms | 40320 KB |
subtask_1_14.txt | RE | 137 ms | 40320 KB |
subtask_1_15.txt | RE | 140 ms | 40320 KB |
subtask_1_16.txt | RE | 138 ms | 40320 KB |
subtask_1_17.txt | RE | 137 ms | 40320 KB |
subtask_1_18.txt | RE | 137 ms | 40320 KB |