题目链接

题目大意

给定两个序列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. SpringBoot + Shiro + shiro.ini 的踩坑记录

    0.写在前面的话 好久没写博客了,诶,好多时候偷懒直接就抓网上的资料丢笔记里了,也就没有自己提炼,偷懒偷懒.然后最近参加了一个网络课程,要交作业的那种,为了能方便看下其他同学的作业,就写了个爬虫把作业 ...

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

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

  3. Windows OpenSSH 基本用法

    笔者在前文<Windows 支持 OpenSSH 了!>中介绍了 Windows 对 OpenSSH 支持的基本内容,本文在前文的基础上介绍一些 OpenSSH Server 的配置和常见 ...

  4. samba故障:protocol negotiation failed: NT_STATUS_IO_TIMEOUT

    windows下无法访问samba共享目录,若无任何提示则需要到linux服务器上访问samba共享,看下是否有问题提示 故障解决过程:(保证网络通畅) 1.查看samba服务器是否正常,smb服务器 ...

  5. SSH(poderosa)を使って、さくらのMySQLサーバーに接続する方法

    SSH(poderosa)を使って.さくらのMySQLサーバーに接続する方法の覚書. 現在のさくらサーバーでは.新規ユーザーはTELNETが使えない.なので.データベースをコマンドラインで操作するには ...

  6. python第一章:简介与安装--小白博客

    Python简介 Python是一种计算机程序设计语言.是一种动态的.面向对象的脚本语言,最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越来越多被用于独立的.大型项 ...

  7. UnderWater+SDN论文之五

    Underwater Sensor Networks with Mobile Agents: Experience from the Field Source: LNICST 2013 论文是来自两个 ...

  8. Stack Sorting CodeForces - 911E (思维+单调栈思想)

    Let's suppose you have an array a, a stack s (initially empty) and an array b (also initially empty) ...

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

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

  10. 关于JS动画和CSS3动画的性能差异

    本文章为综合其它资料所得. 根据Google Developer,Chromium项目里,渲染线程分为main thread和compositor thread. 如果CSS动画只是改变transfo ...