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. java 泛型的简单使用

    effecttive java一直推荐使用泛型,简单的看了一下泛型的使用 package cn.com.fzk; import java.util.ArrayList; import java.uti ...

  2. 常用CSS设置

    主要内容: 一.容器类 二.文本类 三.特效类 一.容器类 1.background-image:url('img/02.gif');   设置背景图(可以是动态图) 2.background-col ...

  3. c++大作业五子棋-需求分析与设计方案

    写在前边: 本来上学期就已经完成这个大作业,临近考试太忙. 而且老师最后要查重,就没有把代码放上来. 如需整个工程,移步http://download.csdn.net/detail/sdzuiaid ...

  4. 关于ansible变量的一个问题

    ansible-playbook 使用with_items 时 items中 如果有变量 {} 外面可以用 “” items中 如果都是固定值,没有用到变量,{}最外面不要加 “” ,不然报错,mmp

  5. 英语发音规则---oo

    英语发音规则---oo 一.总结 一句话总结: 1.重读音节词尾的字母组合oo发音素[u:]的音? too [tu:] adv.太;也 zoo [zu:] n.动物园 room [ru:m] n.房间 ...

  6. POJ 2309 BST(二叉搜索树)

    思路:除以2^k,找到商为奇数的位置,k为层数,有2^(k+1)-1个节点 这里直接用位运算,x & -x 就求出 2^k 了. #include<iostream> using ...

  7. C# 往excel出力数据

    /// <summary> /// 出力Excel /// </summary> /// <param name="storeModelForExcel&quo ...

  8. vmware在桥接模式下配置centos7网络

    首先要将Vmware10.0.3设置为桥接模式. CentOS 7.0默认安装好之后是没有自动开启网络连接的! cd  /etc/sysconfig/network-scripts/  #进入网络配置 ...

  9. vue-mixins使用注意事项和高级用法

    因为在项目中 mixins(混合)特性使用频率是很高的 有必要熟练掌握官方文档: mixins 实际项目中 一般都存在 列表(list) 这种很常见的使用场景 话再多都不如上demo file: mi ...

  10. web项目路径如何更改