codeforces 840A Leha and Function
来源:互联网 发布:淘宝卖家手机号采集器 编辑:程序博客网 时间:2024/05/16 03:41
http://codeforces.com/problemset/problem/840/A
题目意思的算最小期望,给出2行数,第二行代表的是期望计算的概率,只不过是分子部分(可以这么看);
然后计算第一行的数字乘以第二行数字的总和最小,将重新排序后的第一行数字输出。
其实只要在输入的时候加入一个代表顺序的优先级变量来记录顺序就好了,然后就可以随心所欲的按要求对号入座了。
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>using namespace std;struct node{int num;int xu;int na;}sum[222222];bool cmp1(node x,node y){if(x.num==y.num)return x.xu>y.xu;return x.num<y.num;}bool cmp2(node x,node y){return x.xu<y.xu;}bool cmp3(int x,int y){return x>y;}int main(){int n,k;while(cin>>n){ int a[222222]; int i; for(i=0;i<n;i++) { scanf("%d",&a[i]);}for(i=0;i<n;i++){ scanf("%d",&sum[i].num); sum[i].xu=i;}sort(a,a+n,cmp3);sort(sum,sum+n,cmp1);for(i=0;i<n;i++)sum[i].na=a[i];sort(sum,sum+n,cmp2);int q=0;for(i=0;i<n;i++){if(q++)cout<<" ";cout<<sum[i].na;}cout<<endl;}return 0;}
阅读全文
0 0
- 【Codeforces 840 A. Leha and Function】& 构造
- codeforces 840A Leha and Function
- Codeforces 840A Leha and Function
- Leha and Function CodeForces
- Leha and Function CodeForces
- A. Leha and Function
- Codeforces Round #429 (Div. 2) 840A Leha and Function(贪心)
- Codeforces Round #429 (Div. 2):C、&840A、 Leha and Function
- codeforces 841C Leha and Function
- Codeforces-429-2-C Leha and Function
- C. Leha and Function
- cf840A Leha and function
- codeforces Div.2 #429 B.Godsend C. Leha and Function
- CodeForces 841C (C) Leha and Function 贪心
- 429c Leha and Function
- Codeforces 840B:Leha and another game about graph
- codeforces #429(div2)C—Leha and Function(水题)
- Codeforces_841_C Leha and Function(贪心+构造|规律)
- 使用opencv2变换图片大小
- linux中的firewalld服务
- 模拟Java内省的功能
- java网络爬虫解决方案
- C/S总结
- codeforces 840A Leha and Function
- 2017/8/19训练日记(被虐|_'))
- Friend-Graph 1003
- 待深入理解
- zzuli 2180 GJJ的日常之沉迷数学(逆元)
- Java——Java集合List
- 关于Ubuntu14.04中多版本anaconda与Python及pip三者管理一些方法
- JDBC数据库连接需要注意的问题
- Python学习——九九乘法表的编制