Submission #90007
Source Code Expand
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int N,M,P,X[205],Y[205],minx,miny;
int DP[605][605];
int solve(int N,int M)
{
if(N < minx || M < miny) return N*M;
int i,a=N*M;
if(DP[N][M] != -1) return DP[N][M];
for(i=0;i<P;i++)
if(X[i] <= N && Y[i] <= M)
a=min(a,min( solve(X[i],M-Y[i])+solve(N-X[i],M) , solve(N-X[i],Y[i])+solve(N,M-Y[i]) ));
return DP[N][M] = a;
}
int main()
{
int i,j;
memset(DP,-1,sizeof(DP));
scanf("%d %d",&N,&M);
scanf("%d",&P);
for(i=0;i<P;i++)
{
scanf("%d %d",&X[i],&Y[i]);
if(!i) { minx=X[i]; miny=Y[i]; }
else { minx=min(minx,X[i]); miny=min(miny,Y[i]); }
}
printf("%d\n",solve(N,M));
return 0;
}
Submission Info
Submission Time
2013-07-15 18:50:24+0900
Task
13 - Phidias
User
BurakYuksel
Language
C++ (G++ 4.6.4)
Score
100
Code Size
813 Byte
Status
AC
Exec Time
427 ms
Memory
2316 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:31:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:32:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:36:33: 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
27 ms
2216 KB
02
AC
26 ms
2312 KB
03
AC
33 ms
2236 KB
04
AC
27 ms
2212 KB
05
AC
25 ms
2280 KB
06
AC
27 ms
2200 KB
07
AC
26 ms
2244 KB
08
AC
26 ms
2244 KB
09
AC
25 ms
2208 KB
10
AC
28 ms
2232 KB
11
AC
42 ms
2232 KB
12
AC
184 ms
2316 KB
13
AC
300 ms
2216 KB
14
AC
288 ms
2236 KB
15
AC
335 ms
2316 KB
16
AC
203 ms
2228 KB
17
AC
409 ms
2236 KB
18
AC
326 ms
2236 KB
19
AC
281 ms
2240 KB
20
AC
427 ms
2240 KB