Submission #1107898
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,Ma,Mb; int a[50],b[50],c[50]; int dp[50][500][500]; int main(){ cin>>n>>Ma>>Mb; for(int i=0; i<n; i++) { cin>>a[i]>>b[i]>>c[i]; } for(int i=0; i<50; 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+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]); dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]); } } } int mindp=inf; for(int i=1; i<500; i++) { for(int j=1; j<500; j++) { int g=__gcd(i,j); if(i/g==Ma && j/g==Mb) { mindp=min(mindp,dp[n][i][j]); } } } if(mindp==inf) { cout<< -1<<endl; return 0; } cout<<mindp<<endl; }
Submission Info
Submission Time | |
---|---|
Task | A - One Card Poker |
User | aim_cpo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2098 Byte |
Status | WA |
Exec Time | 82 ms |
Memory | 49024 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | WA | 79 ms | 49024 KB |
sample_02.txt | WA | 76 ms | 49024 KB |
sample_03.txt | WA | 82 ms | 49024 KB |
subtask_1_01.txt | WA | 80 ms | 49024 KB |
subtask_1_02.txt | WA | 76 ms | 49024 KB |
subtask_1_03.txt | WA | 75 ms | 49024 KB |
subtask_1_04.txt | WA | 81 ms | 49024 KB |
subtask_1_05.txt | WA | 79 ms | 49024 KB |
subtask_1_06.txt | WA | 76 ms | 49024 KB |
subtask_1_07.txt | WA | 79 ms | 49024 KB |