Submission #76722
Source Code Expand
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#define REP(i,m) for(int i=0;i<m;++i)
#define REPN(i,m,in) for(int i=in;i<m;++i)
#define ALL(t) (t).begin(),(t).end()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define dump(x) cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
using namespace std;
static const int INF =500000000;
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
typedef long long int lint;
typedef pair<int,int> pi;
int w,h;
int n;
pi rect[205];
int dp[1000][1000];
int main(){
scanf("%d%d%d",&w,&h,&n);
REP(i,n) scanf("%d%d",&rect[i].fr,&rect[i].sc);
sort(rect,rect+n);rect[n].fr=INF;
for(int i=1;i<=h;++i) for(int j=1;j<=w;++j){
dp[i][j]=i*j;
/* for(int k=1;k<=i/2;++k){
dp[i][j]=min(dp[i][j],dp[k][j]+dp[i-k][j]);
}
for(int k=1;k<=j/2;++k){
dp[i][j]=min(dp[i][j],dp[i][k]+dp[i][j-k]);
}*/
for(int k=0;rect[k].fr<=j;++k) if(rect[k].sc<=i){
dp[i][j]=min(dp[i][j],min(dp[rect[k].sc][j-rect[k].fr]+dp[i-rect[k].sc][j],
dp[i-rect[k].sc][rect[k].fr]+dp[i][j-rect[k].fr]));
}
}
printf("%d\n",dp[h][w]);
return 0;
}
Submission Info
Submission Time
2013-03-30 19:44:56+0900
Task
13 - Phidias
User
hogloid
Language
C++ (G++ 4.6.4)
Score
100
Code Size
1250 Byte
Status
AC
Exec Time
144 ms
Memory
2908 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:25:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:26:48: 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
25 ms
888 KB
02
AC
24 ms
904 KB
03
AC
23 ms
880 KB
04
AC
24 ms
1020 KB
05
AC
23 ms
1028 KB
06
AC
23 ms
908 KB
07
AC
25 ms
988 KB
08
AC
24 ms
896 KB
09
AC
23 ms
868 KB
10
AC
23 ms
912 KB
11
AC
28 ms
1520 KB
12
AC
59 ms
2448 KB
13
AC
94 ms
2564 KB
14
AC
87 ms
2692 KB
15
AC
99 ms
2440 KB
16
AC
60 ms
1540 KB
17
AC
128 ms
2908 KB
18
AC
104 ms
2424 KB
19
AC
87 ms
2704 KB
20
AC
144 ms
2816 KB