Submission #330197


Source Code Expand

#include<bits/stdc++.h>

using namespace std;

#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define lli long long int
#define pii pair<int,int>
#define mod 1000000007
#define N (int)1e6+10
#define mp make_pair
#define pb push_back
#define nd second
#define st first
#define endl '\n'
#define inf mod
#define sag (sol|1)
#define sol (root<<1)
#define ort ((bas+son)>>1)

int dp[606][606];
int n,m,k,i,j,a,b;
int arr[606][2];

int f(int a,int b){
    if(dp[a][b])
        return dp[a][b];

    if(!a or !b)
        return 0;

    for(int i=1 ; i<=k ; i++){
        int x = arr[i][0];
        int y = arr[i][1];
        if(x>a or y>b)
            continue;
        int t = max(f(a-x,y) + f(a,b-y) , f(a-x,b) + f(x,b-y) ) + x*y;
        dp[a][b] = max(t,dp[a][b]);
    }

    return dp[a][b];
}

int main(){

    cin >> n >> m;

    cin >> k;

    for(i=1 ; i<=k ; i++)
        cin >> arr[i][0] >> arr[i][1];

    cout << n*m-f(n,m) << endl;

}

Submission Info

Submission Time
Task 13 - Phidias
User ykaya
Language C++ (G++ 4.6.4)
Score 95
Code Size 1004 Byte
Status TLE
Exec Time 1033 ms
Memory 2080 KB

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 0 / 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
TLE × 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 25 ms 800 KB
02 AC 24 ms 804 KB
03 AC 25 ms 924 KB
04 AC 24 ms 804 KB
05 AC 25 ms 736 KB
06 AC 24 ms 932 KB
07 AC 24 ms 808 KB
08 AC 24 ms 804 KB
09 AC 24 ms 796 KB
10 AC 24 ms 932 KB
11 AC 52 ms 1384 KB
12 AC 437 ms 1700 KB
13 AC 526 ms 1700 KB
14 AC 878 ms 1700 KB
15 AC 580 ms 1824 KB
16 AC 270 ms 1832 KB
17 AC 918 ms 1888 KB
18 AC 608 ms 2080 KB
19 AC 877 ms 1700 KB
20 TLE 1033 ms 1824 KB