Submission #1107826
Source Code Expand
#include <bits/stdc++.h> #define rep(i,a,b) for(int i=(a); i<(b); i++) #define all(c) (c).begin(),(c).end() #define rall(c) (c).rbegin(),(c).rend() #define sort(v,n) sort(v,v+n); #define vsort(v) sort(v.begin(),v.end()); #define vvsort(v) sort(v.begin(),v.end(),greater<int>()); #define ll long long #define pb(a) push_back(a) #define fi first #define se second #define inf 999999999 using namespace std; typedef pair<int,int> p; typedef pair<ll,ll> lp; typedef priority_queue<int> pq; typedef priority_queue<int,vector<int>,greater<int> > rpq; bool is_uruu(int y) { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); } const ll MOD=1e9+7; const double PI=acos(-1.0); //----------------------------------------------------------------------------------------------------------------------------------// int n,m,l; int a[41],b[41],c[41]; int dp[500][500][50]; int main(){ cin>>n>>m>>l; for(int i=0; i<n; i++) { cin>>a[i]>>b[i]>>c[i]; } for(int i=0; i<500; i++) { for(int j=0; j<500; j++) { for(int k=0; k<50; k++) { dp[i][j][k]=inf; } } } dp[0][0][0]=0; for(int i=0; i<500; i++) { for(int j=0; j<500; j++) { for(int k=0; k<n; k++) { dp[i+a[k]][j+b[k]][k+1]=min(dp[i+a[k]][j+b[k]][k+1],dp[i][j][k]+c[k]); dp[i][j][k+1]=min(dp[i][j][k+1],dp[i][j][k]); } } } int dpmin=inf; for(int i=0; i<500; i++) { for(int j=0; j<500; j++) { int g=__gcd(i,j); if(i/g==m && j/g==l) { dpmin=min(dpmin,dp[i][j][n]); } } } if(dpmin==inf) { cout<< -1<<endl; }else{ cout<<dpmin<<endl; } }
Submission Info
Submission Time | |
---|---|
Task | D - Mixing Experiment |
User | aim_cpo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2089 Byte |
Status | RE |
Exec Time | 224 ms |
Memory | 49024 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 | 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 | RE | 181 ms | 49024 KB |
sample_02.txt | RE | 175 ms | 49024 KB |
subtask_1_01.txt | RE | 190 ms | 49024 KB |
subtask_1_02.txt | RE | 178 ms | 49024 KB |
subtask_1_03.txt | RE | 191 ms | 49024 KB |
subtask_1_04.txt | RE | 195 ms | 49024 KB |
subtask_1_05.txt | RE | 200 ms | 49024 KB |
subtask_1_06.txt | RE | 196 ms | 49024 KB |
subtask_1_07.txt | RE | 209 ms | 49024 KB |
subtask_1_08.txt | RE | 210 ms | 49024 KB |
subtask_1_09.txt | RE | 202 ms | 49024 KB |
subtask_1_10.txt | RE | 220 ms | 49024 KB |
subtask_1_11.txt | RE | 224 ms | 49024 KB |
subtask_1_12.txt | RE | 212 ms | 49024 KB |
subtask_1_13.txt | RE | 215 ms | 49024 KB |
subtask_1_14.txt | RE | 216 ms | 49024 KB |
subtask_1_15.txt | RE | 213 ms | 49024 KB |
subtask_1_16.txt | RE | 212 ms | 49024 KB |
subtask_1_17.txt | RE | 213 ms | 49024 KB |
subtask_1_18.txt | RE | 212 ms | 49024 KB |