###### UVA 10163 Storage Keepers

#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <utility>
using namespace std;

#define rep(i,j,k) for (int i=j;i<=k;i++)
#define Rrep(i,j,k) for (int i=j;i>=k;i--)

#define Clean(x,y) memset(x,y,sizeof(x))
#define LL long long
#define ULL unsigned long long
#define inf 0x7fffffff
#define mod 100000007
int n,m;
int a[50];
int dp[109];//dp[i]前i个仓库的最小安全系数的最大值。
int g[109]; //前i个仓库满足最优解的最小费用

void solve()
{
rep(i,1,m) //枚举每个人进行背包
Rrep(j,n,1)
{
int k = min( a[i] , j );
rep(p,1,k) //这个人看守p个仓库
dp[j] = max( dp[j] , min( dp[j-p] , a[i] / p ) );
}
int Q = dp[n];
if ( Q == 0 )
{
puts("0 0");
return;
}
rep(i,1,m) //前i个人
Rrep(j,n,1) //前j个仓库
{
int k = min( j , a[i] );
Rrep(p,k,1)
if ( a[i]/p >= Q ) //不小于最小值
g[j] = min( g[j] , g[j-p] + a[i] );
}
cout<<dp[n]<<" "<<g[n]<<endl;
}

int main()
{
while( cin>>n>>m )
{
if ( n + m == 0 ) break;
Clean(dp,0);
Clean(g,0);
dp[0] = 99999;
rep(i,1,m) scanf("%d",&a[i]);
solve();
}
return 0;
}


#### uva 10163 - Storage Keepers(01背包）

2013-09-21 10:26:24

#### UVA 10163 - Storage Keepers（dp）

2013-08-05 15:23:54

#### 100道动态规划——13 UVA 10163 Storage Keepers 有约束条件下的DP，递推，不能使用结构体作为基本单位

2016-11-16 16:32:56

#### uva 10163 Storage Keepers

2014-02-07 10:50:23

#### Storage Keepers UVA - 10163

2017-08-17 20:57:56

#### uva 10163——Storage Keepers

2015-12-13 20:16:13

#### UVa 10163 Storage Keepers

2015-06-07 19:47:36

#### UVA 10163 - Storage Keepers

2014-10-02 14:40:27

#### UVA - 10163 Storage Keepers

2013-10-07 21:33:06

#### uva 10163 Storage Keepers

2018-01-02 14:43:00

## 不良信息举报

UVA 10163 Storage Keepers