Codeforces 798D Mike and distribution (构造)
题目链接
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 (构造)相关推荐
- CodeForces - 798D Mike and distribution(构造+思维/玄学随机数)
题目链接:点击查看 题目大意:给出两个长度为n的数列,现在要求选出n/2+1个位置,使得两个序列中这些位置的和分别大于各自序列之和的一半 题目分析:题意换句话说,是需要让我们从数组中选出一半,要大于另 ...
- CF Round410 D. Mike and distribution
D. Mike and distribution 构造法 798D - Mike and distribution In the beginning, it's quite easy to notic ...
- CodeForces - 798B Mike and strings
B. Mike and strings time limit per test2 seconds memory limit per test256 megabytes inputstandard in ...
- CodeForces 798D 思维,贪心
CodeForces 798D 题意:长度为 n的两个数组 a[]和 b[],要找出 k ( k<=n/2+1 )个下标,使得在两个数组中这 k个数的和乘上 2 要大于所有数的和. tags: ...
- 【CodeForces - 798D】Mike and distribution (思维构造,贪心,黑科技)
题干: Mike has always been thinking about the harshness of social inequality. He's so obsessed with it ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces 1276C/1277F Beautiful Rectangle (构造)
题目链接 http://codeforces.com/contest/1276/problem/C 题解 嗯,比赛结束前3min想到做法然后rush不出来了--比赛结束后又写了15min才过-- 以下 ...
最新文章
- 三分钟学会css3中的flexbox布局
- 年度BCI奖 |THE ANNUAL BCI AWARD
- PSAM卡---中国人民银行PSAM卡管理规范.doc
- Log4Net 最简配置
- Java 8中的instanceof运算符和访客模式替换
- 驰骋工作流引擎,工作流程管理系统.业务人员常见的问题?
- 虚拟机讲只读文件变为可读可写文件_Linux虚拟机文件系统突然变成只读
- Object.preventExtensions()使用技巧
- [转载] python自定义error_Python 自定义异常处理Error函数
- IPv4中IP地址分类
- 思科CCNA电子教程
- 雨木林风 的 Ylmf OS
- 【JVM】JVM基础
- 打开优盘显示要格式化怎么办?
- torch.nn到底是什么?(精简版)
- 关于word中插入的mathtype公式变形问题的解决方案
- 微信隐藏/显示右上角菜单接口
- 大疆 L1 任务文件格式说明(CLC/CLI/CMI/IMU/LDR/MNF/RTB/RTK/RTL/RTS/JPG/MOV)
- 兔子拔萝卜的java游戏_幼儿园中班体育游戏教案详案《小兔拔萝卜》
- python药店销售数据分析_Python数据分析实例一:医院药品销售数据