队列的基本操作

来源:互联网 发布:数据库去掉重复行 编辑:程序博客网 时间:2024/04/25 16:42
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <queue>
#include <list>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <iostream>
#include <stack>
#include <assert.h>
#include <time.h>
using namespace std;


queue<int> q;
int a[110000];


bool cmp(int x, int y)
{
return x > y;
}


int main()
{
int i, t, j, n, ans, cy;
scanf("%d", &t);
while (t--)
{
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
sort(a, a + n, cmp);
while (!q.empty())
{
q.pop();
}
ans = 1;
q.push(a[0]);
for (i = 1; i < n; i++)
{
cy = q.front();
if (cy >= 2 * a[i])
{
q.pop();
q.push(a[i]);
}
else
{
q.push(a[i]);
}
}
printf("%d\n", q.size());
}
return 0;
}
原创粉丝点击