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 对于二 ...
随机推荐
- 使用adb进行关机(转载)
转自:http://hi.baidu.com/fangqianshu/item/dc52b92d31b2dd1542634a3d 其实进入adb shell,然后执行reboot -p或者直接在命令行 ...
- HTTP Status 500 - Could not write content: could not initialize proxy - no Session
分析出现no Session错误的原因以及给出解决方案: 使用SpringMVC + JSON数据返回时,经常会出现no Session的错误: 报错原因:因为懒加载在提取关联对象的属性值的时候发现E ...
- Django day25 序列化组件(*****)
序列化:将变量从内存中存储或传输的过程称之为序列化 1.序列化组件是干什么用的? 对应着表,写序列化的类 2.如何使用序列化组件 Serializer 1) 重命名:用source:xx = seri ...
- 汇编程序44:检测点13.1 (jmp near ptr 标号指令的中断例程)
安装程序: assume cs:code //jmp near ptr 标号指令的替代实现,使用iret指令 code segment start: mov ax,cs mov ds,ax mov s ...
- 为什么选择Android Studio 而是 Eclipse
Android Studio 现在的版本已经比较稳定了,刚出来时也是各种BUG,自己用了下,摸索了一天,感觉挺好的. 优点之一:代码提示和搜索功能非常强大,非常智能. 1).自定义theme有个名字叫 ...
- 342 Power of Four 4的幂
给定一个整数 (32位有符整数型),请写出一个函数来检验它是否是4的幂.示例:当 num = 16 时 ,返回 true . 当 num = 5时,返回 false.问题进阶:你能不使用循环/递归来解 ...
- java.net.URISyntaxException: Illegal character in query
java使用httpclient爬取一个网站的时候,请求:String url3="http://sh.58.com/ershoufang/33562546149042x.shtml?amp ...
- C# linq学习【转】
在说LINQ之前必须先说说几个重要的C#语言特性 一:与LINQ有关的语言特性 1.隐式类型 (1)源起 在隐式类型出现之前, 我们在声明一个变量的时候, 总是要为一个变量指定他的类型 甚至在fore ...
- Spring Cloud (10) Hystrix-监控面板
Hystrix DashBoard 断路器是根据一段时间窗内的请求状况来判断并操作断路器的打开和关闭状态的.Hystrix Dashboard是作为断路器状态的一个组件,提供了数据监控和友好的图形化界 ...
- Spring Cloud (7) 服务容错保护-Hystrix服务降级
在微服务架构中,根据业务来拆分成一个个的服务,服务与服务之间可以互相调用,在Spring Cloud可以用RestTemplate+Ribbon和Feign来调用.为了保证其高可用,单个服务通常会集群 ...