Submission #176168


Source Code Expand

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,b;
int x[205],y[205];
void read(){
	int i;
	scanf("%d %d %d",&a,&b,&n);
	for(i=1;i<=n;i++)
		scanf("%d %d",&x[i],&y[i]);
}
int mat[605][605];
void solve(){
	int i,j,k;
	for(i=1;i<=a;i++){
		for(j=1;j<=b;j++){
			mat[i][j]=min(mat[i-1][j]+j,mat[i][j-1]+i);
			for(k=1;k<=n;k++)
				if(x[k]<=i && y[k]<=j)
					mat[i][j]=min(mat[i][j],min(mat[i-x[k]][y[k]]+mat[i][j-y[k]],mat[i-x[k]][j]+mat[x[k]][j-y[k]]));
		}
	}
	printf("%d\n",mat[a][b]);
}
int main(){
	read();
	solve();
	return 0;
}

Submission Info

Submission Time
Task 13 - Phidias
User halilozanakgul
Language C++ (G++ 4.6.4)
Score 100
Code Size 618 Byte
Status AC
Exec Time 267 ms
Memory 2252 KB

Compile Error

./Main.cpp: In function ‘void read()’:
./Main.cpp:10:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:12:29: 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 42 ms 860 KB
02 AC 26 ms 824 KB
03 AC 24 ms 824 KB
04 AC 23 ms 916 KB
05 AC 24 ms 920 KB
06 AC 26 ms 876 KB
07 AC 24 ms 964 KB
08 AC 24 ms 924 KB
09 AC 26 ms 876 KB
10 AC 26 ms 920 KB
11 AC 31 ms 1448 KB
12 AC 99 ms 1756 KB
13 AC 145 ms 1832 KB
14 AC 155 ms 1828 KB
15 AC 163 ms 2064 KB
16 AC 93 ms 1968 KB
17 AC 225 ms 1964 KB
18 AC 183 ms 2212 KB
19 AC 160 ms 1984 KB
20 AC 267 ms 2252 KB