429c Leha and Function
题目

解题报告
F(n, k)是在集合{1, 2, 3, ..., n}中所有的具有k个元素的子集中分别取最小值,相加后的期望。
例如:要求F(4, 2) ,根据定义有{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4},则F(4, 2)=(1+1+1+2+2+3)/6=1.6666666666666...
对于F(n, k),我们有这么一个结论,
$$ F(n, k) > F(m, k), n > m $$
$$F(n, k) > F(n, q), k < q $$
因此,原问题变为将A按照由大到小排序后,求B数组每个元素在排序后的编号,在此位置输出排序后的Ai
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
#define REP(i, k, n) for (int i = k; i < n; i++)
#define REPP(i, k, n) for (int i = k; i <= n; i++)
const int inf = 0x3f3f3f3f;
#define LOCAL
int a[200005], h[200005];
pair<int, int> b[200005];
bool cmp(int a, int b)
{
return a > b;
}
bool cmp1(pair<int, int> a, pair<int, int> b)
{
return a.first < b.first;
}
int main(int argc, char * argv[])
{
#ifdef LOCAL
freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.in", "r", stdin);
//freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.out", "w", stdout);
#endif
int n;
while (~scanf("%d", &n))
{
REPP(i, 1, n)
scanf("%d", a+i);
REPP(i, 1, n)
{
scanf("%d", &b[i].first);
b[i].second = i;
}
sort(a+1, a+n+1, cmp);
sort(b+1, b+n+1, cmp1);
REPP(i, 1, n)
h[b[i].second] = i;
REPP(i, 1, n)
printf("%d ", a[h[i]]);
printf("\n");
}
return 0;
}
429c Leha and Function的更多相关文章
- Codeforces Round #429 (Div. 2/Div. 1) [ A/_. Generous Kefa ] [ B/_. Godsend ] [ C/A. Leha and Function ] [ D/B. Leha and another game about graph ] [ E/C. On the Bench ] [ _/D. Destiny ]
PROBLEM A/_ - Generous Kefa 题 OvO http://codeforces.com/contest/841/problem/A cf 841a 解 只要不存在某个字母,它的 ...
- CodeForces 840A - Leha and Function | Codeforces Round #429 (Div. 1)
/* CodeForces 840A - Leha and Function [ 贪心 ] | Codeforces Round #429 (Div. 1) A越大,B越小,越好 */ #includ ...
- 【CodeForces】841C. Leha and Function(Codeforces Round #429 (Div. 2))
[题意]定义函数F(n,k)为1~n的集合中选择k个数字,其中最小数字的期望. 给定两个数字集A,B,A中任意数字>=B中任意数字,要求重组A使得对于i=1~n,sigma(F(Ai,Bi))最 ...
- [Codeforces 841C]Leha and Function
题目大意:定义函数F(n,k)为[1,2,3,..n]中k个元素的子集中最小元素的数学期望.现在给你两个长度相等的数列A,B(A中元素严格大于B中元素),现在要你重新排列A,使得$\sum\limit ...
- 【Codeforces Round #429 (Div. 2) C】Leha and Function
[Link]:http://codeforces.com/contest/841/problem/C [Description] [Solution] 看到最大的和最小的对应,第二大的和第二小的对应. ...
- 朱世杰恒等式的应用-以CF841C为例
题目大意 Codeforces 841C Leha and Function. 令\(F(n,k)\)为在集合\(\{x|x \in [1,n]\}\)中选择一个大小为k的子集,最小元素的期望值. 给 ...
- Codeforces Round #429 (Div. 2) 补题
A. Generous Kefa 题意:n个气球分给k个人,问每个人能否拿到的气球都不一样 解法:显然当某种气球的个数大于K的话,就GG了. #include <bits/stdc++.h> ...
- Codeforces Round #429 (Div. 2)
A. Generous Kefa One day Kefa found n baloons. For convenience, we denote color of i-th baloon as ...
- codeforces Round#429 (Div2)
2017-08-20 10:00:37 writer:pprp 用头文件#include <bits/stdc++.h>很方便 A. Generous Kefa codeforces 84 ...
随机推荐
- [K/3Cloud] 调用其他界面时通过Session传递对象参数
DynamicFormShowParameter参数的CustomParams参数列表只支持string类型的参数,对于复杂参数的传递需要通过单据View对象的共享Session来完成,如: 在调用界 ...
- Java操作redis【二十】
1.首先需要将redis的绑定地址为127.0.0.1去掉,同时将redis的保护模式去掉,并且开放6379端口. 如果是保护模式需要输入密码才能连接. (1)去掉绑定地址: (2)去掉保护模式: ( ...
- Linux下汇编语言学习笔记66 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- Mac 系统引导过程概述 & BootCamp 的秘密
http://bbs.feng.com/read-htm-tid-6890655.html
- js下载
下载用ajax不好使,得用表单提交的方式 download:function(url,paramObj){ var doc = document; //使用一个隐藏的form表单执行提交,没有则创建 ...
- Spring PropertyPlaceholderConfigure 载入配置文件
在開始这篇博客的主题之前,我们先来了解一下Spring配置文件以及包括的相关内容. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2 ...
- [TypeScript] Collect Related Strings in a String Enum in TypeScript
As of TypeScript 2.4, it is now possible to define string enums, or more precisely, enums with strin ...
- Apple Swift编程语言新手教程
文件夹 1 简单介绍 2 Swift入门 3 简单值 4 控制流 5 函数与闭包 6 对象与类 7 枚举与结构 1 简单介绍 今天凌晨Apple刚刚公布了Swift编程 ...
- android:省市县三级联动(基于json和spring)
一.请看效果图": 二.程序的代码: 1.MainActivity.java package com.loveplusplus.loader.demo.ui; import org.json ...
- mystr = '{}{}{}'.format(mystr, random.randint(0, 9), adurl)
mystr = '{}{}{}'.format(mystr, random.randint(0, 9), adurl)