【待补】UPC No Need(二分+bitset || 背包dp)

简介: 【待补】UPC No Need(二分+bitset || 背包dp)

No Need

题目描述

AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is ai. Because he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.

Then, for each card i, he judges whether it is unnecessary or not, as follows:

If, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.

Otherwise, card i is NOT unnecessary.

Find the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.


Constraints

All input values are integers.

1≤N≤5000

1≤K≤5000

1≤ai≤109(1≤i≤N)

Partial Score

300 points will be awarded for passing the test set satisfying N,K≤400.

输入

The input is given from Standard Input in the following format:

N K

a1 a2 … aN

输出

Print the number of the unnecessary cards.

样例输入 Copy

3 6

1 4 3

样例输出 Copy

1

提示

There are two good sets: {2,3} and {1,2,3}.

Card 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.

For card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.

Neither is card 3 for a similar reason, hence the answer is 1.


待补

先把博客扔这:

背包dp

二分+bitset

bitset介绍及常用用法

目录
相关文章
|
2月前
|
人工智能
PTA-求最大值及其下标
求最大值及其下标
12 0
|
15天前
PTA-第4章-12 求满足条件的斐波那契数
摘要:该问题要求编写程序找出大于输入正整数n的最小斐波那契数。斐波那契数列是前两项之和构成后续项的数列,起始为1、1。给定输入样例n=10,输出为13。代码通过while循环计算,直至找到第一个大于n的斐波那契数,并将其输出。
16 5
|
2月前
|
人工智能
PTA-排序问题
排序问题
13 0
|
11月前
|
机器学习/深度学习 人工智能
51nod 1055 最长等差数列 (dp好题)
51nod 1055 最长等差数列 (dp好题)
32 0
UPC 排队(线段树||RMQ||树状数组||分块处理)
UPC 排队(线段树||RMQ||树状数组||分块处理)
48 0
UPC Graph (最小生成树 || 并查集+二分)
UPC Graph (最小生成树 || 并查集+二分)
69 0
|
人工智能 vr&ar
SPOJ - COT Count on a tree(主席树 LCA)
SPOJ - COT Count on a tree(主席树 LCA)
70 0
|
算法 Go C++
UPC Go Home(贪心 || 前缀和+二分)(STL二分函数的使用)
UPC Go Home(贪心 || 前缀和+二分)(STL二分函数的使用)
65 0
UPC山头狙击战--二分
题目描述 Lucky为了掩护大部队,单枪匹马同敌人周旋,后来被敌人包围在某山头……等等,为什么怎么听怎么像狼牙山五壮士!不过不用着急,这次Lucky携带了足够的弹药,完全可以将涌上来的敌人一个一个干掉。Lucky是个神枪手,只要他的枪膛中有子弹,他就能将在他射程m(用从敌人位置到山头的直线距离算)以内的一个敌人瞬间射杀。但如果在射程内没有敌人,出于节约子弹考虑和面子问题,Lucky会等待敌人靠近然后射击。
93 0
|
搜索推荐
PTA——7-28 排序
PTA——7-28 排序
91 0