Submission #181634


Source Code Expand

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int n,m,k;
int x[205],y[205];
int dp[605][605];

int rec(int t,int s)
{
	if(dp[t][s] != 1e9) return dp[t][s];
	int res = 1e9;
	for(int i=0;i<k;i++)
	{
		if(x[i] == t)
		{
			res = min(res,x[i]*(s%y[i]));
		}
		if(y[i] == s)
		{
			res = min(res,y[i]*(t%x[i]));
		}
	}
	
	for(int i=1;i<t;i++) res = min(res,rec(i,s)+rec(t-i,s));
	for(int i=1;i<s;i++) res = min(res,rec(t,i)+rec(t,s-i));
	return dp[t][s] = res;
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<k;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
	}
	for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) dp[i][j] = 1e9;
	printf("%d\n",rec(n,m));
}

Submission Info

Submission Time
Task 13 - Phidias
User IH19980412
Language C++ (G++ 4.6.4)
Score 40
Code Size 740 Byte
Status TLE
Exec Time 1033 ms
Memory 2332 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:38:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name Set01 Set02 Set03 Set04 Set05 Set06 Set07 Set08 Set09 Set10 Set11 Set12 Set13 Set14 Set15 Set16 Set17 Set18 Set19 Set20
Score / Max Score 5 / 5 5 / 5 5 / 5 0 / 5 5 / 5 0 / 5 0 / 5 5 / 5 5 / 5 0 / 5 0 / 5 5 / 5 0 / 5 0 / 5 0 / 5 5 / 5 0 / 5 0 / 5 0 / 5 0 / 5
Status
AC × 1
AC × 1
AC × 1
TLE × 1
AC × 1
TLE × 1
TLE × 1
AC × 1
AC × 1
TLE × 1
TLE × 1
AC × 1
TLE × 1
TLE × 1
TLE × 1
AC × 1
TLE × 1
TLE × 1
TLE × 1
TLE × 1
Set Name Test Cases
Set01 01
Set02 02
Set03 03
Set04 04
Set05 05
Set06 06
Set07 07
Set08 08
Set09 09
Set10 10
Set11 11
Set12 12
Set13 13
Set14 14
Set15 15
Set16 16
Set17 17
Set18 18
Set19 19
Set20 20
Case Name Status Exec Time Memory
01 AC 21 ms 808 KB
02 AC 171 ms 932 KB
03 AC 23 ms 752 KB
04 TLE 1029 ms 936 KB
05 AC 21 ms 804 KB
06 TLE 1029 ms 936 KB
07 TLE 1029 ms 940 KB
08 AC 316 ms 932 KB
09 AC 21 ms 812 KB
10 TLE 1028 ms 888 KB
11 TLE 1030 ms 1576 KB
12 AC 890 ms 1696 KB
13 TLE 1029 ms 1828 KB
14 TLE 1030 ms 1952 KB
15 TLE 1029 ms 2080 KB
16 AC 418 ms 1960 KB
17 TLE 1029 ms 2092 KB
18 TLE 1028 ms 2212 KB
19 TLE 1029 ms 1964 KB
20 TLE 1033 ms 2332 KB