Shadowman loves to collect box but his roommates woogieman and itman don't like box and so shadowman wants to hide boxes as many as possible. A box can be kept hidden inside of another box if and only if the box in which it will be held is empty and the size of the box is at least twice as large as the size of the box.

Print the minimum number of box that can be shown.

Input

The input set starts with single line integer T (1<=T<=50) the number of test cases. Then following T cases starts with an integer N (1<=N<=100000) denoting the number of box. The next line contains N space separated positive integer. i-th of them contains a numbers Ai(1<=Ai<=100000) size of the i-th box.

Output

Output the the case number and the minimum number of box that can be shown.

Example

Input:
2
4
1 2 4 8
4
1 3 4 5 Output:
Case 1: 1
Case 2: 3

n个盒子要叠起来,大小为k的盒子可以放进大小为2k的空盒子里,问最少剩多少

排个序贪心就好了,维护一个队列表示当前可以塞到其他盒子里的盒子,每次新来一个盒子的时候,把最小的那个塞进去

最后答案就是队列大小了

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define mkp(a,b) make_pair(a,b)
#define pi 3.1415926535897932384626433832795028841971
#define mod 100007
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int n,t,w,ans;
int q[];
int a[];
inline void work(int cur)
{
n=read();
for (int i=;i<=n;i++)a[i]=read();
sort(a+,a+n+);
t=w=ans=;
for (int i=;i<=n;i++)
{
if (t==w)q[++w]=a[i]*,ans++;
else if (q[t+]<=a[i])t++,q[++w]=a[i]*;
else q[++w]=a[i]*,ans++;
}
printf("Case %d: %d\n",cur,ans);
}
int main()
{
int T=read(),tt=;
while (T--)work(++tt);
}

Spoj VISIBLEBOX

Spoj-VISIBLEBOX Decreasing Number of Visible Box的更多相关文章

  1. SPOJ:Decreasing Number of Visible Box(不错的,背包?贪心?)

    Shadowman loves to collect box but his roommates woogieman and itman don't like box and so shadowman ...

  2. 【SPOJ】NUMOFPAL - Number of Palindromes(Manacher,回文树)

    [SPOJ]NUMOFPAL - Number of Palindromes(Manacher,回文树) 题面 洛谷 求一个串中包含几个回文串 题解 Manacher傻逼题 只是用回文树写写而已.. ...

  3. Spoj MKTHNUM - K-th Number

    题目描述 English Vietnamese You are working for Macrohard company in data structures department. After f ...

  4. SPOJ - VISIBLEBOX [multiset的使用]

    tags:[STL][sort][贪心]题解:做法:先对数组a进行排序,再将数组a从头到尾扫一遍,使用multiset维护最小值,如果,即将放入集合的数字>=最小值的两倍,那我们就删除掉多重集合 ...

  5. spoj 7001. Visible Lattice Points GCD问题 莫比乌斯反演

    SPOJ Problem Set (classical) 7001. Visible Lattice Points Problem code: VLATTICE Consider a N*N*N la ...

  6. 数论 - 欧拉函数的运用 --- poj 3090 : Visible Lattice Points

    Visible Lattice Points Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5636   Accepted: ...

  7. poj 3060 Visible Lattice Points

    http://poj.org/problem?id=3090 Visible Lattice Points Time Limit: 1000MS   Memory Limit: 65536K Tota ...

  8. P8 Visible Lattice Points

    P8 Visible Lattice Points Time Limit:1000ms,     Memory Limit:65536KB Description A lattice point (x ...

  9. 【POJ】3090 Visible Lattice Points(欧拉函数)

    Visible Lattice Points Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7705   Accepted: ...

随机推荐

  1. leetcode_1095. Find in Mountain Array_[Binary Search]

    https://leetcode.com/problems/find-in-mountain-array/ 题意:给定一个MountainArray(定义见题目),找到其中最早出现的target值的下 ...

  2. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 长时间没连接mysql断开了, ...

  3. Linux之centos7 VMware安装教程

    Linux系统安装 下面是centOS7的安装过程 VMware 系统搭建 1 新建虚拟机 2 选择自定义 3 选择稍后安装操作系统 4 选择操作系统的版本Linux centos64位 5 选择处理 ...

  4. Sublime Text 套件介紹(四):Pretty JSON

    JSON,一個輕量級的資料交換語言,目前許多網站AJAX request的回應結果都是JSON格式   以下是一個標準的JSON格式   { "firstName": " ...

  5. 利用VS自带的命令行工具查看和生产PublicKeyToken

    使用VS2008(或其他版本)命令行工具,键入:SN -T C:\*****.dll 就会显示出该dll具体的PublicKeyToken数值. 如果该程序集没有强命 名,则不会有PublicKeyT ...

  6. shell脚本,怎么实现每次新开一个shell都输出一个提示语?

    [root@localhost wyb]# cat test.sh echo -e "\033[32mhello,This is wangyuebo's shell\033[0m" ...

  7. 自写小函数处理 javascript 0.3*0.2 浮点类型相乘问题

    const reg = /^([-+]?)([0-9]+)\.([0-9]*)$/; // 判断是不是浮点数 const isFloat = function(number){ return reg. ...

  8. vue 封装分页组件

    分页 一般都是调接口, 接口为这种格式 {code: 0, msg: "success",…} code:0 data:{ content:[{content: "11& ...

  9. UVa 291 The House Of Santa Claus——回溯dfs

    题意:从左下方的1开始,一笔画出圣诞老人的房子. #include <iostream> #include <cstring> using namespace std; ][] ...

  10. Fortran学习笔记5(数组Array)

    数组的声明方式 一维数组 二维数组 多维数组 数组索引值的改变 自定义类型的数组定义 对数组内容的设置 利用隐含式循环设置数组初值 对整个数组操作 对部分数组的操作 where函数 Forall函数 ...