Submission #163676


Source Code Expand

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

using namespace std;

int dp[SIZE][SIZE];
int vx[SIZE],vy[SIZE];

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[i]=a;
		vx[i]=b;
	}
	sort(vy,vy+n);
	sort(vx,vx+n);
	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]]);
					}
					else break;
				}
				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 break;
				}
			}
			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 874 Byte
Status AC
Exec Time 190 ms
Memory 2096 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 21 ms 796 KB
02 AC 22 ms 796 KB
03 AC 22 ms 720 KB
04 AC 19 ms 796 KB
05 AC 22 ms 796 KB
06 AC 22 ms 796 KB
07 AC 21 ms 796 KB
08 AC 22 ms 796 KB
09 AC 24 ms 796 KB
10 AC 22 ms 796 KB
11 AC 28 ms 1324 KB
12 AC 78 ms 1680 KB
13 AC 114 ms 1576 KB
14 AC 112 ms 1704 KB
15 AC 126 ms 1712 KB
16 AC 72 ms 1828 KB
17 AC 168 ms 1840 KB
18 AC 133 ms 2096 KB
19 AC 116 ms 1700 KB
20 AC 190 ms 2088 KB