Submission #87946
Source Code Expand
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
#include <stack>
#define f first
#define s second
#define mkp make_pair
#define pb push_back
#define FILL(a,b) memset(a,b,sizeof(a))
#define FOR(a,b,c) for(a=b;a<=c;a++)
#define VFOR(a,b) for(a=0;a<b.size();a++)
#define ll long long
#define INF (int)1000000000
#define LINF (ll)1e16
#define vi vector<int>
using namespace std;
int N,M,K;
int H,W;
pair < int ,int > P[205];
int DP[605][605];
int solve(int h,int w)
{
if(DP[h][w]!=-1) return DP[h][w];
int i,mn=h*w,a,b;
FOR(i,1,N)
if(P[i].f <= h && P[i].s <= w)
{
a=solve(P[i].f,w-P[i].s)+solve(h-P[i].f,w);
b=solve(h-P[i].f,P[i].s)+solve(h,w-P[i].s);
mn=min(mn,min(a,b));
}
return DP[h][w]=mn;
}
int main()
{
int i,j;
FILL(DP,-1);
scanf(" %d %d",&H,&W);
scanf(" %d",&N);
FOR(i,1,N)
scanf(" %d %d",&P[i].f,&P[i].s);
printf("%d\n",solve(H,W));
return 0;
}
Submission Info
Submission Time
2013-07-06 17:20:36+0900
Task
13 - Phidias
User
oyildiz
Language
C++ (G++ 4.6.4)
Score
100
Code Size
1001 Byte
Status
AC
Exec Time
417 ms
Memory
2216 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:46:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:47:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:49:34: 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
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
2204 KB
02
AC
22 ms
2192 KB
03
AC
22 ms
2192 KB
04
AC
23 ms
2192 KB
05
AC
23 ms
2208 KB
06
AC
22 ms
2216 KB
07
AC
22 ms
2192 KB
08
AC
21 ms
2192 KB
09
AC
21 ms
2104 KB
10
AC
22 ms
2200 KB
11
AC
34 ms
2200 KB
12
AC
164 ms
2204 KB
13
AC
275 ms
2204 KB
14
AC
263 ms
2196 KB
15
AC
308 ms
2188 KB
16
AC
157 ms
2100 KB
17
AC
382 ms
2176 KB
18
AC
297 ms
2040 KB
19
AC
262 ms
2116 KB
20
AC
417 ms
2196 KB