CF410div2 D. Mike and distribution
/*
CF410div2 D. Mike and distribution
http://codeforces.com/contest/798/problem/D
构造
题意:给出两个数列a,b,求选出n/2+1个数对,使得其和的二倍大于各自的数列
思路:对数列a进行排序,因为可以选一半加1个,所以最大的那个我们选出来
然后在剩下的数列中,每隔两个选则b中较大的,
这样可以保证选出的在b中满足条件,并且在a中也满足条件
然而。。。。我他喵的居然忘了读入b数列!!!!
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <map>
#include <set>
//#define test
using namespace std;
const int Nmax=1e6+;
long long a[Nmax],b[Nmax];
int m;
long long s1,s2;
long long now1,now2;
int book[Nmax];
struct Node
{
int a;
int id;
}num[Nmax];
bool cmp(Node a,Node b)
{
return a.a>b.a;
}
int ans[Nmax];
int main()
{
#ifdef test
#endif
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%lld",&a[i]);
num[i].id=i;
num[i].a=a[i];
}
for(int i=;i<=n;i++)//忘了读入b[],真是醉了,感觉最近不适合写代码。。。
scanf("%lld",&b[i]);
sort(num+,num++n,cmp);
int ans_size=;
int i=;
ans[++ans_size]=num[i++].id;
for(;i<=n;i+=)
{
if(i==n)
{
ans[++ans_size]=num[i].id;
break;
}
if(b[num[i].id]>b[num[i+].id])
ans[++ans_size]=num[i].id;
else
ans[++ans_size]=num[i+].id;
}
printf("%d\n",ans_size);
for(int i=;i<=ans_size;i++)
printf("%d%c",ans[i],i==ans_size?'\n':' ');
return ;
}
CF410div2 D. Mike and distribution的更多相关文章
- codeforces 798 D. Mike and distribution
D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- #410div2D. Mike and distribution
D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- D. Mike and distribution 首先学习了一个玄学的东西
http://codeforces.com/contest/798/problem/D D. Mike and distribution time limit per test 2 seconds m ...
- Codeforces 798D Mike and distribution(贪心或随机化)
题目链接 Mike and distribution 题目意思很简单,给出$a_{i}$和$b_{i}$,我们需要在这$n$个数中挑选最多$n/2+1$个,使得挑选出来的 $p_{1}$,$p_{2} ...
- CF410div2 B. Mike and strings
/* CF410div2 B. Mike and strings http://codeforces.com/contest/798/problem/B 字符串 暴力 题意:给你n个串,每次操作可以将 ...
- CF410div2 A. Mike and palindrome
/* CF410div2 A. Mike and palindrome http://codeforces.com/contest/798/problem/A 水题 */ #include <c ...
- CF798D Mike and distribution
CF798D Mike and distribution 洛谷评测传送门 题目描述 Mike has always been thinking about the harshness of socia ...
- Codeforces 798D Mike and distribution - 贪心
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it tha ...
- 【算法系列学习】codeforces D. Mike and distribution 二维贪心
http://codeforces.com/contest/798/problem/D http://blog.csdn.net/yasola/article/details/70477816 对于二 ...
随机推荐
- TS流解析 四
一 从TS流开始 数字电视机顶盒接收到的是一段段的码流,我们称之为TS(Transport Stream,传输流),每个TS流都携带一些信息,如Video.Audio以及我们需要学习的PAT.PMT等 ...
- webrtc学习资源
http://www.imaotao.cn/project/webrtc-201604
- HDFS你一定要知道,要考的
你肯定听过Hadoop,对就是那头奔跑的小象. Hadoop作为大数据时代代表性的解决方案被大家所熟知,它主要包含两部分内容: HDFS分布式文件存储 MapReduce分布式计算框架 前面我们分析存 ...
- linux设置库文件加载包含路径
第一种方式vim /etc/ld.so.conf 将要包含的路径添加到此文件中退出重新登录使配置生效或者执行命令source /etc/ld.so.conf 另一种方式利用LIBRARY_PATH和L ...
- Laravel (5.5.33) 加载过程(二)
本次说明代码 /* |-------------------------------------------------------------------------- | Turn On The ...
- Android 自己搭建一个直播系统吧
服务端用 SRS(Simple Rtmp Server),在这里下载simple-rtmp-server需要Linux系统最好是Ubuntu,装个Ubuntu虚拟机就行了在Linux里,解压缩SRS ...
- Android 8.0 启动后台service 出错 IllegalStateException: Not allowed to start service Intent
错误原因: Android 8.0 不再允许后台service直接通过startService方式去启动, 具体行为变更如下: 如果针对 Android 8.0 的应用尝试在不允许其创建后台服务的情况 ...
- cms中某些标题链接的单独写法
href="{$CATEGORYS[45][url]}" 链接写法, {$CATEGORYS[45][catname]} 标题写法 在show页面中 src="{$thu ...
- [转]Learn SQLite in 1 hour
转载说明: 1.原文地址:http://www.askyb.com/sqlite/learn-sqlite-in-1-hour/ 2.译文地址:http://www.oschina.net/quest ...
- Python标准库os
如果你希望自己的程序能够与平台无关的话,这个模块至关重要. os.name #'nt' for windows, 'posix' for linux/unix os.getcwd() #get cur ...