Submission #3051524


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n,ma,mb,ans=1e9;
    scanf("%d%d%d",&n,&ma,&mb);
    int a[n],b[n],c[n];
    for (int i=0; i<n; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
    }
    int d[n+1][100*n+2][100*n+2];
    for (int i=0; i<=n; i++){
        for (int j=0; j<=100*n; j++){
            for (int k=0; k<=100*n; k++){
                d[i][j][k]=1e9;
            }
        }
    }
    d[0][0][0]=0;
    for (int i=0; i<n; i++){
        for (int j=0; j<=100*n; j++){
            for (int k=0; k<=100*n; k++){
                d[i+1][j][k]=fmin(d[i+1][j][k],d[i][j][k]);
                d[i+1][j+a[i]][k+b[i]]=fmin(d[i+1][j+a[i]][k+b[i]],d[i][j][k]+c[i]);
            }
        }
    }
    for (int j=1; j<=100*n; j++){
        for (int k=1; k<=100*n; k++){
            if (j*mb==k*ma){
                if(ans>d[n-1][j][k]){
                    ans=d[n-1][j][k];
                }
            }
        }
    }
    if (ans==1e9){
        printf("-1\n");
    } else {
        printf("%d\n",ans);
    }
	return 0 ;
}

Submission Info

Submission Time
Task D - Mixing Experiment
User SpokenLib
Language C (GCC 5.4.1)
Score 0
Code Size 1176 Byte
Status RE
Exec Time 543 ms
Memory 241152 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:10:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&ma,&mb);
     ^
./Main.c:13:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&a[i],&b[i],&c[i]);
         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
RE × 2
AC × 1
RE × 19
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 RE 98 ms 1536 KB
sample_02.txt RE 96 ms 256 KB
subtask_1_01.txt RE 108 ms 6016 KB
subtask_1_02.txt AC 1 ms 640 KB
subtask_1_03.txt RE 105 ms 6016 KB
subtask_1_04.txt RE 175 ms 43392 KB
subtask_1_05.txt RE 265 ms 92800 KB
subtask_1_06.txt RE 543 ms 241152 KB
subtask_1_07.txt RE 95 ms 128 KB
subtask_1_08.txt RE 95 ms 128 KB
subtask_1_09.txt RE 95 ms 128 KB
subtask_1_10.txt RE 95 ms 128 KB
subtask_1_11.txt RE 96 ms 128 KB
subtask_1_12.txt RE 96 ms 128 KB
subtask_1_13.txt RE 96 ms 128 KB
subtask_1_14.txt RE 97 ms 128 KB
subtask_1_15.txt RE 96 ms 128 KB
subtask_1_16.txt RE 96 ms 128 KB
subtask_1_17.txt RE 97 ms 128 KB
subtask_1_18.txt RE 96 ms 128 KB