Codeforces
来源:互联网 发布:淘宝联盟qq群推广步揍 编辑:程序博客网 时间:2024/05/21 02:51
题意:这道题题意有点难懂,大概的意思就是找到一个排列使得对应的a,b的期望最大化
解题思路:观察样例……得出B小对应A大,所以两个排序就可以了……其实就是使得期望最大,贪心的去选就好了。
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <algorithm>#include <string.h>#include <math.h>#include <vector>#include <set>#include <map>#include <queue>#include <stack>#define ll long longusing namespace std;int a[200005];struct point{ int num; int i;}b[200005];bool cmp(point a,point b){ return a.num>b.num;}int ans[200005];int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); for(int i=0;i<n;i++){ b[i].i=i; scanf("%d",&b[i].num); } sort(a,a+n); sort(b,b+n,cmp); for(int i=0;i<n;i++){ ans[b[i].i]=a[i]; } for(int i=0;i<n;i++) printf("%d ",ans[i]); return 0;}
阅读全文
1 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Foul Play UVA
- POJ 2996 Help Me with the Game(模拟)
- Linux下nodejs(一):UEditor 使用
- CSS中清除浮动的方式探究
- SLF4J: Class path contains multiple SLF4J bindings.
- Codeforces
- HTTP协议—— 简单认识TCP/IP协议
- Android将Excel表格解析成json文件
- POJ 2993 Emag eht htiw Em Pleh(模拟)
- Listener等外部类获取Spring Bean
- URL URI 两者存在的区别
- [玩耍]Python实现备份CSDN博客(未完成)
- tensorflow 学习笔记10 网络模型的保存与提取
- 如何设计出MySQL高性能表