当前位置:网站首页>Educational Codeforces Round 117 (Rated for Div. 2)E. Messages
Educational Codeforces Round 117 (Rated for Div. 2)E. Messages
2022-06-26 13:58:00 【__ LazyCat__】
The question
The topic is mainly about a tutor who wants to give n n n Students sent messages , He can send to all students at the same time m m m Bar message , Then everyone has something that the tutor wants to send him m i m_{i} mi Information and k i k_{i} ki Number of times to view messages , If the number of messages sent by the professor is less than k i k_{i} ki Words , And this m m m This message contains what the student wants to see m i m_{i} mi Bar message , Then add one to the number of people who see the news ( Because I must have seen the news ). If the number of messages sent is greater than k i k_{i} ki , When there is news that the student needs to read , He will be at random m m m Choose one of the messages k i k_{i} ki Subset of messages , There is a certain probability of seeing the required information , Expectation plus probability times one . Now ask how to choose the message to send so that all students have the greatest expectation of seeing the information they need to see . Output any message set .
Ideas
First, observe the given data range , Found to have 2 ∗ 1 0 5 2*10^5 2∗105 A student , It's a little bit big . But we found that k k k Small values , Only 20 20 20 . This shows that we can learn from k k k It is worth starting to solve this problem . When the expected number of people received is the highest , The number of messages we can send is actually no more than 20 20 20 Of , Because it's bigger than 20 20 20 No one will be 100% likely to receive the information they need , And every additional piece of information , Everyone's expectations will drop before . Therefore, it is bold to guess that the number of messages sent is not greater than 20 20 20 .( Actually, I won't prove ) .
Answer key
Now that you can enumerate information numbers , Then we can enumerate the expectation of the maximum number of recipients for the same information number . In enumerating information numbers i i i when , For the first j j j For people who need to receive information , The probability is ( expect ) Namely min ( 1 , k i ) \min(1,\frac{k}{i}) min(1,ik) , No more than 1 1 1 It's obvious , about k i \frac{k}{i} ik With the following certificates :
Let's say that a person has checked the number of times k i k_{i} ki Less than the number of messages currently sent n, Then the probability can be solved by the combination number , by ( n − 1 k − 1 ) ( n k ) \frac {\binom {n-1}{k-1} }{\binom{n}{k}} (kn)(k−1n−1)( The total number of schemes is at n n n Take whatever you like k k k strip , The number of schemes that meet the conditions is to get the required information first , And then in n − 1 n -1 n−1 Take the rest of the k − 1 k-1 k−1 strip ), Then, the combination number reduction can be expanded to obtain k n \frac{k}{n} nk.
Then you can sort the largest by bubbling i i i Information expectations , It is found that the sending quantity is i i i The expectation of the maximum number of recipients and the corresponding scheme . Finally, compare and take the maximum value among all the numbers sent , Output this scheme .
PS: Why bubble ? We can find out just to find the biggest 20 Number , Direct full sequence sorting complexity takes off directly , Bubbling can greatly reduce the number of exchanges .
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<double,int> P;
const int maxn=2e5+5;
int n,u,v,w,xk,mx;
double ans;
P pre[30][30];
struct node{
int m,k;
}t[maxn];
vector<int>vt,cnt[maxn];
ll vs[30];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>t[i].m>>t[i].k; mx=max(mx,t[i].m);
cnt[t[i].m].push_back(t[i].k);
}
for(int i=1;i<=20;i++)
{
for(int j=1;j<=mx;j++)
{
double tmp=0;
for(auto k:cnt[j])
{
tmp+=min(1.0,k*1.0/i);
}
int top=i+1;
pre[i][top]=P(tmp,j);
while(pre[i][top]>pre[i][top-1]&&top-1)
{
swap(pre[i][top],pre[i][top-1]),top--;
}
}
}
for(int i=1;i<=20;i++)
{
double tmp=0;
for(int j=1;j<=i;j++)tmp+=pre[i][j].first;
if(ans<tmp)ans=tmp,xk=i;
}
cout<<xk<<"\n";
for(int i=1;i<=xk;i++)cout<<pre[xk][i].second<<" ";
return 0;
}
边栏推荐
- [MySQL from introduction to mastery] [advanced part] (II) representation of MySQL directory structure and tables in the file system
- Insect operator overloaded a fun
- ES6 module
- What is the use of index aliases in ES
- Formal parameters vs actual parameters
- 7-2 the cubic root of a number
- 33、使用RGBD相机进行目标检测和深度信息输出
- 【Proteus仿真】Arduino UNO按键启停 + PWM 调速控制直流电机转速
- 7-16 monetary system I
- Wechat applet Registration Guide
猜你喜欢

8. Ribbon load balancing service call

Zero basics of C language lesson 7: break & continue

MediaPipe手势(Hands)

Pointer

Wechat applet -picker component is repackaged and the disabled attribute is added -- above

Global variable vs local variable

网络远程访问的方式使用树莓派

Postman自动化接口测试

Wechat applet Registration Guide

Detailed introduction to shell script (4)
随机推荐
爱可可AI前沿推介(6.26)
Exercise set 1
Detailed practical sharing, two hours of funny videos after work, earning more than 7000 a month
Awk tools
33. Use rgbd camera for target detection and depth information output
Nlp-d60-nlp competition D29
character constants
Global variable vs local variable
What is the use of index aliases in ES
虫子 STL string上
虫子 内存管理 下 内存注意点
Es common grammar I
虫子 类和对象 中
12 SQL optimization schemes summarized by old drivers (very practical)
Design of simple digital circuit traffic light
同花顺股票开户选哪个证券公司是比较好,比较安全的
Is expression of D
Firewall introduction
Pointer
Luogu p3426 [poi2005]sza-template solution