Submission #163675


Source Code Expand

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define SIZE 605

using namespace std;

int dp[SIZE][SIZE];
vector <int> vx,vy;

int main()
{
	int w,h;
	scanf("%d %d",&w,&h);
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		dp[a][b]=-1;
		vy.push_back(a);
		vx.push_back(b);
	}
	for(int i=1;i<=w;i++)
	{
		for(int j=1;j<=h;j++)
		{
			if(dp[i][j]!=-1)
			{
				dp[i][j]=i*j;
				for(int k=0;k<n;k++)
				{
					if(vx[k]<j)
					{
						dp[i][j]=min(dp[i][j],dp[i][vx[k]]+dp[i][j-vx[k]]);
					}
				}
				for(int k=0;k<n;k++)
				{
					if(vy[k]<i)
					{
						dp[i][j]=min(dp[i][j],dp[vy[k]][j]+dp[i-vy[k]][j]);
					}
				}
			}
			else dp[i][j]=0;
		}
	}
	printf("%d\n",dp[w][h]);
	return 0;
}

Submission Info

Submission Time
Task 13 - Phidias
User yutaka1999
Language C++ (G++ 4.6.4)
Score 100
Code Size 817 Byte
Status AC
Exec Time 459 ms
Memory 2092 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:17:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:21:23: 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 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5 5 / 5
Status
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 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 22 ms 924 KB
02 AC 22 ms 924 KB
03 AC 19 ms 924 KB
04 AC 21 ms 808 KB
05 AC 21 ms 816 KB
06 AC 23 ms 808 KB
07 AC 21 ms 928 KB
08 AC 22 ms 916 KB
09 AC 20 ms 916 KB
10 AC 20 ms 924 KB
11 AC 35 ms 1456 KB
12 AC 151 ms 1716 KB
13 AC 224 ms 1712 KB
14 AC 253 ms 1724 KB
15 AC 256 ms 1840 KB
16 AC 137 ms 1832 KB
17 AC 374 ms 1836 KB
18 AC 305 ms 2092 KB
19 AC 259 ms 1916 KB
20 AC 459 ms 2068 KB