6 3 2
0
1 1
1 2
1 3
2 2 1
2 2 1

5

【資料規模與約定】

BY BPM

# Code

``````#include <stdio.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <algorithm>
#define rep(i, st, ed) for (int i = st; i <= ed; i  = 1)
#define drp(i, st, ed) for (int i = st; i >= ed; i -= 1)
#define erg(i, st) for (int i = ls[st]; i; i = e[i].next)
#define fill(x, t) memset(x, t, sizeof(x))
#define max(x, y) (x)>(y)?(x):(y)
#define min(x, y) (x)<(y)?(x):(y)
#define ll long long
#define db double
#define INF 0x3f3f3f3f
#define N 1501
#define L 1<<16 | 1
int f[2][L], t[N];
int x=0,v=1; char ch=getchar();
while (ch<'0'||ch>'9'){if(ch=='-')v=-1; ch=getchar();}
while (ch<='9'&&ch>='0'){x=x*10 ch-'0'; ch=getchar();}
return x*v;
}
inline int count(int x){
int cnt = 0;
while (x){
x -= x & (-x);
cnt  = 1;
}
return cnt;
}
int main(void){
rep(i, 1, n){
int s = 0;
t[i] = s;
}
int lim = (1<<m)-1;
rep(i, 0, n - 1){
rep(j, 0, lim){
f[(i   1)&1][j] = max(f[i&1][j], f[(i   1)&1][j]);
f[(i   1)&1][j|t[i 1]] = max(f[i&1][j]   1, f[(i   1)&1][j|t[i 1]]);
}
}
int ans = 0;
rep(i, 0, lim){
if (count(i) <= k){
ans = max(ans, f[n&1][i]);
}
}
printf("%d\n", ans);
return 0;
}``````