hdoj2159

9347 단어 OJ
Problem : 2159 ( FATE )     Judge Status : Accepted RunId : 2628422    Language : G++    Author : huwenbiao Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
/***************************************************************\
*Author:Hu Wenbiao
*Created Time: Sun 18 Jul 2010 08:06:00 PM CST
*File Name: main.cpp
*Description: 。 , ,
*
\***************************************************************/

//*========================*Head File*========================*\\

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*----------------------*Global Variable*----------------------*/
int
n,m,k,s,a,b,bag[
100][100];//bag
//*=======================*Main Program*=======================*//
using namespace std;

int
main(){

//freopen("input","r",stdin);
while(scanf("%d%d%d%d",&n,&m,&k,&s)!=EOF){
memset(bag,
0,sizeof(bag));
while
(k--){
scanf(
"%d%d",&a,&b);
for
(int i=b;i<=m;++i)
//
for(int j=1;j<=s;++j)//
bag[i][j]=max(bag[i][j],bag[i-b][j-1]+a);
}

int
ans=-
1;
for
(int i=
1;ans==-1&&i<=m;++i)
for
(int j=
1;j<=s;++j)
if
(bag[i][j]>=n)
ans=i;
// n , ,
// ,
if(ans!=-1)
ans=m-ans;
printf(
"%d
"
,ans);
}
}

좋은 웹페이지 즐겨찾기