题目链接

题目大意

给定两个序列a,b,要求找到不多于个下标,使得对于a,b这些下标所对应数的2倍大于所有数之和。

N<=100000,所有输入大于0,保证有解。

因为明确的暗示,所以一定找个。

考虑去掉取整符号,分奇偶讨论。

1 n为奇数

将a从大到小排序,首先取最大的,接着每两个数取其中b较大的。

2 n为偶数

将a从大到小排序,首先取最大的和另一个(都可以),接着每两个数取其中b较大的。

 #include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
const int N=;
int n;
struct node
{
int a,b,pos;
}t[N];
bool cmp(node c,node d)
{
return c.a>d.a;
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d",&t[i].a);
for(int i=;i<=n;i++)
scanf("%d",&t[i].b);
for(int i=;i<=n;i++)
t[i].pos=i;
sort(t+,t+n+,cmp);
printf("%d\n",n/+);
printf("%d ",t[].pos);
if(n%==)
{
printf("%d ",t[n].pos);
n--;
}
for(int i=;i<=n;i+=)
if(t[i].b>t[i+].b)
printf("%d ",t[i].pos);
else
printf("%d ",t[i+].pos);
printf("\n");
return ;
}

Codeforces 798D Mike and distribution的更多相关文章

  1. Codeforces 798D Mike and distribution(贪心或随机化)

    题目链接 Mike and distribution 题目意思很简单,给出$a_{i}$和$b_{i}$,我们需要在这$n$个数中挑选最多$n/2+1$个,使得挑选出来的 $p_{1}$,$p_{2} ...

  2. Codeforces 798D Mike and distribution - 贪心

    Mike has always been thinking about the harshness of social inequality. He's so obsessed with it tha ...

  3. CodeForces - 798D Mike and distribution 想法题,数学证明

    题意:给你两个数列a,b,你要输出k个下标,使得这些下标对应的a的和大于整个a数列的和的1/2.同时这些下标对应的b //题解:首先将条件换一种说法,就是要取floor(n/2)+1个数使得这些数大于 ...

  4. Codeforces 798D - Mike and distribution(二维贪心、(玄学)随机排列)

    题目链接:http://codeforces.com/problemset/problem/798/D 题目大意:从长度为n的序列A和序列B中分别选出k个下表相同的数要求,设这两个序列中k个数和分别为 ...

  5. Codeforces 798D Mike and distribution (构造)

    题目链接 http://codeforces.com/contest/798/problem/D 题解 前几天的模拟赛,居然出这种智商题..被打爆了QAQ 这个的话,考虑只有一个序列怎么做,把所有的排 ...

  6. 【算法系列学习】codeforces D. Mike and distribution 二维贪心

    http://codeforces.com/contest/798/problem/D http://blog.csdn.net/yasola/article/details/70477816 对于二 ...

  7. codeforces 798 D. Mike and distribution

    D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  8. D. Mike and distribution 首先学习了一个玄学的东西

    http://codeforces.com/contest/798/problem/D D. Mike and distribution time limit per test 2 seconds m ...

  9. CF410div2 D. Mike and distribution

    /* CF410div2 D. Mike and distribution http://codeforces.com/contest/798/problem/D 构造 题意:给出两个数列a,b,求选 ...

随机推荐

  1. WPF PasswordBox不支持绑定解决方法

    原文:WPF PasswordBox不支持绑定解决方法 PasswordBox的Password属性因为安全原因不支持直接绑定,可以使用依赖属性实现.直接插入代码 public class Passw ...

  2. Java多线程学习(二)---线程创建方式

    线程创建方式 摘要: 1. 通过继承Thread类来创建并启动多线程的方式 2. 通过实现Runnable接口来创建并启动线程的方式 3. 通过实现Callable接口来创建并启动线程的方式 4. 总 ...

  3. Java字符串操作及与C#字符串操作的不同

    每种语言都会有字符串的操作,因为字符串是我们平常开发使用频率最高的一种类型.今天我们来聊一下Java的字符串操作及在某些具体方法中与C#的不同,对于需要熟悉多种语言的人来说,作为一种参考.进行诫勉 首 ...

  4. nodejs源码编译-mipse64el架构

    下载nodejs,node-v6.1.0.tar.gz 链接: https://pan.baidu.com/s/1eCtNBWD5yaKiQIHp3pRKew 提取码: faun 注意对应版本的gcc ...

  5. 我的2017&2018

    最近项目进入验收阶段,所以上班没那么忙碌了,但是怎么说呢,我可能天生是闲不住的主,觉得浑身不自在(我这样的人是不是特别不会享福),此处应该有个笑脸哈. 翻看了博客园好几个大牛写的技术文章,感慨大牛不愧 ...

  6. sczd

  7. freemarker根据模板生成word文件实现导出功能

    一.准备工作 1.创建一个03的word文档,动态的数据用占位符标志占位(如testname).然后另存为word2003的xml文件. 2.格式化xml文件,占位符的位置用${testname}代替 ...

  8. windows 内建环境变量

    PS C:\Windows> ls env: Name Value ---- ----- _NT_SYMBOL_PATH srv*C:\Users\vv\Documents\symbols AL ...

  9. [转帖]Office全版本零售版转换VOL

    Office全版本零售版转换VOL https://blog.51cto.com/10981246/2062137 转成bat 执行 改天试试   @ECHO OFF&PUSHD %~DP0 ...

  10. linux关闭触摸板

    关闭触摸板 sudo modprobe -r psmouse 如果打开触摸板就是: sudo modprobe psmouse