hiho Week 8 register

Ended

Participants:541

Verdict:Accepted
Score:100 / 100
Submitted:2014-08-29 11:02:19

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 <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define clr(a) memset(a,-1,sizeof a)
int dp[2][1<<10],now;
int all,n,m,q;
int w[1005];
inline int one(int st){
    int ret=0;
    while(st) ret++,st-=(st&(-st));
    return ret;
}
int main(){
    scanf("%d%d%d",&n,&m,&q);
    rep(i,0,n) scanf("%d",&w[i]);
    now=0;clr(dp[now]);
    all=(1<<m);
    dp[now][0]=0;
    rep(i,0,n){
        now^=1;clr(dp[now]);
        rep(j,0,all) if(dp[1^now][j]!=-1){
            int st=((j<<1));
            dp[now][st&(all-1)]=max(dp[now][st&(all-1)],dp[1^now][j]);
            st=((st|1)&(all-1));
            if(one(st)<=q){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX