题目链接

http://codeforces.com/contest/798/problem/D

题解

前几天的模拟赛,居然出这种智商题。。被打爆了QAQ

这个的话,考虑只有一个序列怎么做,把所有的排序取最大的当然可以,但是还有一种做法,就是两两分组之后每两个相邻的取大的!!
于是按照\(a\)排序,先取第一个,后面每两个相邻的取b较大的。做完了!

哇这怎么想出来的啊。。。。

代码

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;const int N = 1e5;
int a[N+3],b[N+3],permu[N+3];
vector<int> ans;
int n;bool cmp(int x,int y) {return a[x]>a[y];}int main()
{scanf("%d",&n);for(int i=1; i<=n; i++) scanf("%d",&a[i]);for(int i=1; i<=n; i++) scanf("%d",&b[i]);for(int i=1; i<=n; i++) permu[i] = i;sort(permu+1,permu+n+1,cmp);ans.push_back(permu[1]);for(int i=2; i<=n; i+=2){ans.push_back(b[permu[i]]>b[permu[i+1]] ? permu[i] : permu[i+1]);}printf("%d\n",ans.size());for(int i=0; i<ans.size(); i++) printf("%d ",ans[i]); puts("");return 0;
}

Codeforces 798D Mike and distribution (构造)相关推荐

  1. CodeForces - 798D Mike and distribution(构造+思维/玄学随机数)

    题目链接:点击查看 题目大意:给出两个长度为n的数列,现在要求选出n/2+1个位置,使得两个序列中这些位置的和分别大于各自序列之和的一半 题目分析:题意换句话说,是需要让我们从数组中选出一半,要大于另 ...

  2. CF Round410 D. Mike and distribution

    D. Mike and distribution 构造法 798D - Mike and distribution In the beginning, it's quite easy to notic ...

  3. CodeForces - 798B Mike and strings

    B. Mike and strings time limit per test2 seconds memory limit per test256 megabytes inputstandard in ...

  4. CodeForces 798D 思维,贪心

    CodeForces 798D 题意:长度为 n的两个数组 a[]和 b[],要找出 k ( k<=n/2+1 )个下标,使得在两个数组中这 k个数的和乘上 2 要大于所有数的和. tags: ...

  5. 【CodeForces - 798D】Mike and distribution (思维构造,贪心,黑科技)

    题干: Mike has always been thinking about the harshness of social inequality. He's so obsessed with it ...

  6. 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 ...

  7. Codeforces Round #410 (Div. 2) D. Mike and distribution(贪心)

    Mike has always been thinking about the harshness of social inequality. He's so obsessed with it tha ...

  8. Ozon Tech Challenge 2020 (Div.1 + Div.2) E.Kuroni and the Score Distribution 构造

    传送门 文章目录 题意: 思路: 题意: 思路: 不难想到,长度为nnn的数组最多的满足条件的三元组序列是1,2,3....,n1,2,3....,n1,2,3....,n,对于每一个位置贡献为i−1 ...

  9. Codeforces 1276C/1277F Beautiful Rectangle (构造)

    题目链接 http://codeforces.com/contest/1276/problem/C 题解 嗯,比赛结束前3min想到做法然后rush不出来了--比赛结束后又写了15min才过-- 以下 ...

最新文章

  1. 三分钟学会css3中的flexbox布局
  2. 年度BCI奖 |THE ANNUAL BCI AWARD
  3. PSAM卡---中国人民银行PSAM卡管理规范.doc
  4. Log4Net 最简配置
  5. Java 8中的instanceof运算符和访客模式替换
  6. 驰骋工作流引擎,工作流程管理系统.业务人员常见的问题?
  7. 虚拟机讲只读文件变为可读可写文件_Linux虚拟机文件系统突然变成只读
  8. Object.preventExtensions()使用技巧
  9. [转载] python自定义error_Python 自定义异常处理Error函数
  10. IPv4中IP地址分类
  11. 思科CCNA电子教程
  12. 雨木林风 的 Ylmf OS
  13. 【JVM】JVM基础
  14. 打开优盘显示要格式化怎么办?
  15. torch.nn到底是什么?(精简版)
  16. 关于word中插入的mathtype公式变形问题的解决方案
  17. 微信隐藏/显示右上角菜单接口
  18. 大疆 L1 任务文件格式说明(CLC/CLI/CMI/IMU/LDR/MNF/RTB/RTK/RTL/RTS/JPG/MOV)
  19. 兔子拔萝卜的java游戏_幼儿园中班体育游戏教案详案《小兔拔萝卜》
  20. python药店销售数据分析_Python数据分析实例一:医院药品销售数据

热门文章

  1. 学长毕业日记 :本科毕业论文写成博士论文的神操作20170413
  2. 云炬Android开发教程0 jdk下载与安装教程(小白)
  3. 机器学习中的维度灾难
  4. httos双向认证配置_HTTPS双向验证,如何设置
  5. 提高.NET性能的最佳实践
  6. Nhibernate中的连接超时时事务回滚引发异常的处理方法
  7. 操作系统对比和未来展望
  8. 为什么一定情况下scanf比cin快
  9. 程序的加载和执行(一)——《x86汇编语言:从实模式到保护模式》读书笔记21
  10. 一文看懂Python(五)-----文件篇