hiho Week 8 register

Ended

Participants:541

Verdict:Accepted
Score:100 / 100
Submitted:2014-08-26 11:10:12

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 <iostream>
using namespace std;
int dp[1001][1025];
int w[1001];
int countDigit( int s)
{
    int digit = 0;
    while( s){
        if( s&1) digit++;
        s >>= 1;
    }
    return digit;
}
int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    for( int i = 1; i <= N; i++)
        cin >> w[i];
    for( int i = 1; i <= N; i++)
    for( int s = 0; s < (1<<M-1); s++){
        if( countDigit(s) > Q) { dp[i][s] = 0; continue;}
        if( countDigit(s) < Q)
            dp[i][s] = max( dp[i-1][s/2], dp[i-1][s/2+(1<<(M-2))]);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX