队列的基本操作
来源:互联网 发布:数据库去掉重复行 编辑:程序博客网 时间: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;
}
#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;
}
阅读全文
0 0
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作!
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- 队列的基本操作
- kinect studio的使用方法,模拟kinect2实物进行程序测试
- 机器学习笔记(九) 神经网络的学习
- Spring Cloud | Spring Cloud Bus 使用kafka消息总线、gitlab添加webhooks实现自动刷新配置
- 仿淘宝购物车
- HDU 2222 Keywords Search
- 队列的基本操作
- Tensorflow(r1.4)API--tf.nn.conv2d
- maven3打包报错Failed to execute goal on project testaa: Could not resolve dependencies for project
- 树状数组讲解
- Oracle11gSGA调整方法
- 映射的运用
- 分答项目_知识点_微擎web页面_require
- 数据分布分析
- 用户态和内核态的区别