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.

Example
input
5
8 7 4 8 3
4 2 5 3 7

output
3
1 4 5

分析:按第一组数排序后,先把第一个选上,然后后边按顺序两两配对,每对中选同编号中第二组数较大的那一个数的编号,很容易发现这样选下来两组数都是符合条件的。
#include <bits/stdc++.h>
#define N 100005
using namespace std;
struct thing
{int v,n;friend bool operator < (thing a,thing b){return a.v > b.v;}
}a[N];
int n,cnt,b[N],ans[N];
int main()
{scanf("%d",&n);for(int i = 1;i <= n;i++){scanf("%d",&a[i].v);a[i].n = i;}sort(a+1,a+1+n);for(int i = 1;i <= n;i++) scanf("%d",&b[i]);ans[++cnt] = a[1].n;for(int i = 2;i <= n;i+=2){if(i == n) ans[++cnt] = a[i].n;elseif(b[a[i].n] > b[a[i+1].n]) ans[++cnt] = a[i].n;else ans[++cnt] = a[i+1].n;}cout<<cnt<<endl;for(int i = 1;i <= cnt;i++) cout<<ans[i]<<" ";
}

Codeforces Round #410 (Div. 2) D. Mike and distribution(贪心)相关推荐

  1. Codeforces Round #410 (Div. 2) D. Mike and distribution 思维+数学

    链接: http://codeforces.com/contest/798/problem/D 题意: 给你两个长度为n的数列a和b,让你选n/2+1个下标,使得2*∑ai>suma,2*∑bi ...

  2. Codeforces Round #699 (Div. 2) F - AB Tree(贪心、树上DP)超级清晰,良心题解,看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) F - AB Tree Problem ...

  3. Codeforces Round #297 (Div. 2)C. Ilya and Sticks 贪心

    Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MB Submit: xxx ...

  4. Codeforces Round #361 (Div. 2) B. Mike and Shortcuts bfs

    B. Mike and Shortcuts 题目连接: http://www.codeforces.com/contest/689/problem/B Description Recently, Mi ...

  5. Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 【逆元求组合数 离散化】

    任意门:http://codeforces.com/contest/689/problem/E E. Mike and Geometry Problem time limit per test 3 s ...

  6. Codeforces Round #305 (Div. 1) D. Mike and Fish 欧拉回路

    传送门 文章目录 题意: 思路: 题意: 思路: 欧拉回路经典题. 将其转换成图上问题,对于横纵坐标我们将其分开,对于(x,y)(x,y)(x,y)我们将其横纵坐标连一个无向边,现在问题就转换成了我们 ...

  7. Codeforces Round #324 (Div. 2) E. Anton and Ira 贪心

    E. Anton and Ira Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  8. Codeforces Round #FF (Div. 2) D. DZY Loves Modification 贪心+优先队列

    链接:http://codeforces.com/problemset/problem/447/D 题意:一个n*m的矩阵.能够进行k次操作,每次操作室对某一行或某一列的的数都减p,获得的得分是这一行 ...

  9. Codeforces Round #301 (Div. 2) B. School Marks 构造/贪心

    B. School Marks Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/probl ...

最新文章

  1. AMD透露Epyc服务器芯片更多细节 多方面挑战英特尔至强平台
  2. .net授权获取openid_Asp.Net Core 中IdentityServer4 授权中心之自定义授权
  3. 光伏电站清扫机器人_轻型光伏电站清扫机器人的制作方法
  4. Python 用hashlib求中文字符串的MD5值
  5. 报表式CListCtrl的使用详解初稿
  6. python abc
  7. IOS开发-TableView表视图基础
  8. 4.Kong入门与实战 基于Nginx和OpenResty的云原生微服务网关 --- Kong 的基本功能
  9. java 前后端分离_到底什么是前后端分离?
  10. 【zigbee无线通信模块步步详解】ZigBee3.0模块建立远程网络控制方法
  11. 优化 AIX 6.1 的性能
  12. 使用FFmpeg合并/解密/下载m3u8文件转为mp4格式
  13. TP4056 充电电路学习借鉴
  14. 2021-10-11
  15. 软件设计师-备考知识点总结
  16. Facebook Marketing: Advanced Advertising Facebook营销:高级广告 Lynda课程中文字幕
  17. C++的errorC2039和C2679的解决
  18. 从 .NET 开发人员的角度理解 Excel 对象模型 (From MSDN)
  19. html固定页脚布局及样式,html页脚固定在底部的方法
  20. 抖音如何直播汉字找不同小游戏

热门文章

  1. 数据库同步产品对比三(PAC vs 浪擎镜像产品)
  2. 工作笔记1——利用bat脚本实现批量上传文件到ftp服务器
  3. 抖音项目实现2: api层的实现 | 青训营笔记
  4. 魅族android面试题,魅族前端面试题 - 尝试做
  5. React antd Table 实现单元格点击 表头斜线分组等功能
  6. 计算机毕设Python+Vue-志愿者管理系统(程序+LW+部署)
  7. 利用GPU训练的配置方法(Keras)
  8. 关于问题【无法启动 IIS Express Web 服务器。另一个程序正在使用此文件,进程无法访问。 (0x80070020)】
  9. picker-view中的view的高度修改
  10. 【软件周刊第 23 期】Win10 开发全家桶已集齐:.NET Framework 4.7 和 VS 2017 Update 发布...