Submission #1962274


Source Code Expand

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
int dp[500][500];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<500;i++)for(int j=0;j<500;j++)dp[i][j]=mod;
	dp[0][0]=0;
	for(int i=0;i<a;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		for(int j=499;j>=0;j--)for(int k=499;k>=0;k--){
			if(dp[j][k]>=mod)continue;
			dp[j+p][k+q]=min(dp[j+p][k+q],dp[j][k]+r);
		}
	}
	int ret=mod;
	for(int i=1;i<499;i++){
		int s=b*i;
		int t=c*i;
		if(max(s,t)>=499)continue;
		ret=min(ret,dp[s][t]);
	}
	if(ret>=mod)printf("-1\n");else printf("%d\n",ret);
}

Submission Info

Submission Time
Task D - Mixing Experiment
User tozangezan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 795 Byte
Status AC
Exec Time 9 ms
Memory 1152 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int a,b,c;scanf("%d%d%d",&a,&b,&c);
                                    ^
./Main.cpp:20:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   int p,q,r;scanf("%d%d%d",&p,&q,&r);
                                     ^

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 2 ms 1152 KB
sample_02.txt AC 1 ms 1152 KB
subtask_1_01.txt AC 2 ms 1152 KB
subtask_1_02.txt AC 1 ms 1152 KB
subtask_1_03.txt AC 2 ms 1152 KB
subtask_1_04.txt AC 3 ms 1152 KB
subtask_1_05.txt AC 3 ms 1152 KB
subtask_1_06.txt AC 4 ms 1152 KB
subtask_1_07.txt AC 5 ms 1152 KB
subtask_1_08.txt AC 5 ms 1152 KB
subtask_1_09.txt AC 6 ms 1152 KB
subtask_1_10.txt AC 7 ms 1152 KB
subtask_1_11.txt AC 8 ms 1152 KB
subtask_1_12.txt AC 9 ms 1152 KB
subtask_1_13.txt AC 9 ms 1152 KB
subtask_1_14.txt AC 8 ms 1152 KB
subtask_1_15.txt AC 8 ms 1152 KB
subtask_1_16.txt AC 8 ms 1152 KB
subtask_1_17.txt AC 9 ms 1152 KB
subtask_1_18.txt AC 9 ms 1152 KB