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 对于二 ...
随机推荐
- POJ 1273 Drainage Ditches 最大流
这道题用dinic会超时 用E_K就没问题 注意输入数据有重边.POJ1273 dinic的复杂度为O(N*N*M)E_K的复杂度为O(N*M*M)对于这道题,复杂度是相同的. 然而dinic主要依靠 ...
- bzoj2253
cdq分治+dp 看见三维偏序是cdq,互相包含是最长上升子序列 这个代码是错的 交了两份代码,发现手动出数据是不一样的... 不调了 #include<bits/stdc++.h> us ...
- 网站防止用户复制的js方法
<script type="text/javascript">function stop() {return false;}document.oncontextmenu ...
- [Swift通天遁地]二、表格表单-(5)实现表格下拉和上拉刷新效果
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- C语言编译器为什么能够用C语言编写?
不知道大家有没有想过一个问题:C语言编译器为什么能够用C语言编写? 所谓C语言编译器,就是把编程得到的文件,比如.c,.h的文件,进行读取,并对内容进行分析,按照C语言的规则,将其转换成cpu可以执行 ...
- redis-缓存穿透,缓存雪崩,缓存击穿,并发竞争
目录 缓存穿透 定义 解决方案 利用互斥锁 采用异步更新策略 使用布隆过滤器 空置缓存 缓存雪崩 定义 解决方案 给缓存的加一个随机失效时间 使用互斥锁 双缓存策略 缓存击穿 定义 解决方案 使用互斥 ...
- Centos7 时间不正确修复
查看系统支持的时区列表 timedatectl list-timezones 使用 date -R 查看时区是否正确 date -R 修改时区 timedatectl set-timezone Asi ...
- 自己做的一个android 音视频播放器
欢迎大家下载: http://download.csdn.net/detail/q610098308/8504335
- C#学习-处理Excel
首先先了解下一个Excel文件的组成 1.一个Excel包含多个工作表(Sheet) 2.一个工作表(Sheet)包含多行(Row) 3.一行(Row)包含多个单元格(Cell) 如何判断一个单元 ...
- 慕课网中网页定位导航中js相关问题总结
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...