Submission #1103594


Source Code Expand

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed;
    cout<<setprecision(10);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

typedef vector<int> V;
typedef vector<V> VV;
const LL INF=1e8;
int main(){
    int N,A,B;
    cin>>N>>A>>B;
    VV dp(401,V(401,INF));
    dp[0][0]=0;
    REP(latte,N){
        int a,b,c;
        cin>>a>>b>>c;
        auto nxt=dp;
        for(int i=a;i<=400;i++)
            for(int j=b;j<=400;j++)
                chmin(nxt[i][j],dp[i-a][j-b]+c);
        swap(dp,nxt);
    }
    int M=A,K=B,res=INF;
    for(;M<=400&&K<=400;M+=A,K+=B)
        chmin(res,dp[M][K]);
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;

    return 0;
}

Submission Info

Submission Time
Task D - Mixing Experiment
User btk15049
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1168 Byte
Status AC
Exec Time 20 ms
Memory 1536 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 20
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 3 ms 1536 KB
sample_02.txt AC 2 ms 1536 KB
subtask_1_01.txt AC 4 ms 1536 KB
subtask_1_02.txt AC 2 ms 1536 KB
subtask_1_03.txt AC 4 ms 1536 KB
subtask_1_04.txt AC 6 ms 1536 KB
subtask_1_05.txt AC 8 ms 1536 KB
subtask_1_06.txt AC 10 ms 1536 KB
subtask_1_07.txt AC 11 ms 1536 KB
subtask_1_08.txt AC 12 ms 1536 KB
subtask_1_09.txt AC 14 ms 1536 KB
subtask_1_10.txt AC 17 ms 1536 KB
subtask_1_11.txt AC 19 ms 1536 KB
subtask_1_12.txt AC 20 ms 1536 KB
subtask_1_13.txt AC 20 ms 1536 KB
subtask_1_14.txt AC 20 ms 1536 KB
subtask_1_15.txt AC 20 ms 1536 KB
subtask_1_16.txt AC 20 ms 1536 KB
subtask_1_17.txt AC 20 ms 1536 KB
subtask_1_18.txt AC 20 ms 1536 KB