hiho week 195 register

Ended

Participants:264

Verdict:Accepted
Score:100 / 100
Submitted:2018-03-24 23:06:25

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
#define maxn 100010
#define INF 0x3f3f3f3f
using namespace std;
int m, n, mp[11][11], dp[maxn];
void opack(int c,int w){
    for(int i=m;i>=c;i--)
        dp[i] = max(dp[i], dp[i-c]+w);
}
void cpack(int c,int w){
    for(int i=c;i<=m;i++)
        dp[i] = max(dp[i], dp[i-c]+w);
}
void dpack(int c,int w){
    int num = mp[c][w];
    if(c*num >= m){
        cpack(c, w);
        return ;
    }
    int t = 1;
    while(t<num){
        opack(t*c, t*w);
        num -= t;
        t *= 2;
    }
    opack(num*c, num*w);
}
int main(){
    int a, b;
    scanf("%d%d", &n, &m);
    for(int i=0;i<n;i++){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX