D. Mike and distribution
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length neach which he uses to ask people some quite peculiar questions.

To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to  because it will be to easy to find sequence P if he allowed you to select too many elements!

Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.

On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.

On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.

Output

On the first line output an integer k which represents the size of the found subset. k should be less or equal to .

On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 100009
struct node{
int index,num;
}a[N],b[N];
int c[N],k;
int n;
bool cmp(node a,node b){
return a.num>b.num;
}
int main(){
cin>>n;
for(int i=;i<n;i++){
cin>>a[i].num;
a[i].index=i+;
}
for(int i=;i<n;i++){
cin>>b[i].num;
b[i].index=i+;
}
sort(a,a+n,cmp);
c[k++]=a[].index;
for(int i=;i<n;i+=){
if(b[a[i].index-].num>=b[a[i+].index-].num){
c[k++]=b[a[i].index-].index;
}else{
c[k++]=b[a[i+].index-].index;
}
}
printf("%d\n",k);
for(int i=;i<k;i++){
printf("%d ",c[i]);
}
}

#410div2D. Mike and distribution的更多相关文章

  1. codeforces 798 D. Mike and distribution

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

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

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

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

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

  4. CF410div2 D. Mike and distribution

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

  5. CF798D Mike and distribution

    CF798D Mike and distribution 洛谷评测传送门 题目描述 Mike has always been thinking about the harshness of socia ...

  6. Codeforces 798D Mike and distribution - 贪心

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

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

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

  8. Mike and distribution CodeForces - 798D (贪心+思维)

    题目链接 TAG: 这是我近期做过最棒的一道贪心思维题,不容易想到,想到就出乎意料. 题意:给定两个含有N个正整数的数组a和b,让你输出一个数字k ,要求k不大于n/2+1,并且输出k个整数,范围为1 ...

  9. Codeforces 798D Mike and distribution

    题目链接 题目大意 给定两个序列a,b,要求找到不多于个下标,使得对于a,b这些下标所对应数的2倍大于所有数之和. N<=100000,所有输入大于0,保证有解. 因为明确的暗示,所以一定找个. ...

随机推荐

  1. 如何解决Asp.Net MVC和WebAPI的Controller名称不能相同的问题

    1.问题描述 假如有一个文章的业务(Article),我们在 Controllers文件夹中创建MVC Controller和Api Controller,各个Controller中都有相同的获取文章 ...

  2. 3.22课·········CSS样式表

    CSS(Cascading Style Sheet,叠层样式表),作用是美化HTML网页. /*注释区域*/    此为注释语法 一.样式表 (一)样式表的分类 1.内联样式表 和HTML联合显示,控 ...

  3. Linux电源管理(2)-Generic PM基本概念和软件架构【转】

    本文转载自:http://www.wowotech.net/pm_subsystem/generic_pm_architecture.html 1. 前言 这里的Generic PM,是蜗蜗自己起的名 ...

  4. <a href

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEnco ...

  5. 侠客群控引擎二次开发SDK可用方法大全(持续更新)

    如这篇文章所示 http://www.xiake.net/blog/archives/1 侠客的插件SDK能提供很强大的功能(所有官方使用的方法都有提供) 这篇文章是详细介绍所有SDK可调用的方法 首 ...

  6. mysqldump导出格式

    #导出大表:mysqldump --add-drop-table --single-transaction --triggers -R -quick --disable-keys -utest -pt ...

  7. Docker-为镜像添加SSH服务

    进入容器的办法有很多,包括exec.attach等命令,但是这些命令都无法解决远程管理容器的问题,因此,需要SSH的支持 基于commit命令创建 docker提供了docker commit命令,支 ...

  8. Docker学习(三)

    查看docker daemon服务运行状态 service docker status

  9. Java -- 键盘输入 Scanner, BufferedReader。 系统相关System,Runtime。随机数 Randrom。日期操作Calendar

    1. Scanner 一个基于正则表达式的文本扫描器,他有多个构造函数,可以从文件,输入流和字符串中解析出基本类型值和字符串值. public class Main { public static v ...

  10. C++的栈

    栈,是一种存储受限的线性数据结构,在存储和访问数据的时候只能访问栈的一端.栈类似于一摞盘子,只能拿去最上面的盘子,也只能把盘子放到最上面.由于这种特点,栈是一种后进先出(Last in / First ...