CF268E.Playlist

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Manao's friends often send him new songs. He never listens to them right away. Instead, he compiles them into a playlist. When he feels that his mind is open to new music, he opens the playlist and starts to listen to the songs.

Of course, there are some songs that Manao doesn't particuarly enjoy. To get more pleasure from the received songs, he invented the following procedure of listening to the playlist:

  • If after listening to some song Manao realizes that he liked it, then he remembers it and starts to listen to the next unlistened song.
  • If after listening to some song Manao realizes that he did not like it, he listens to all the songs he liked up to this point and then begins to listen to the next unlistened song.

For example, if Manao has four songs in the playlist, A, B, C, D (in the corresponding order) and he is going to like songs A and C in the end, then the order of listening is the following:

  1. Manao listens to A, he likes it, he remembers it.
  2. Manao listens to B, he does not like it, so he listens to A, again.
  3. Manao listens to C, he likes the song and he remembers it, too.
  4. Manao listens to D, but does not enjoy it and re-listens to songs A and C.

That is, in the end Manao listens to song A three times, to song C twice and songs B and D once. Note that if Manao once liked a song, he will never dislike it on a subsequent listening.

Manao has received n songs: the i-th of them is l__i seconds long and Manao may like it with a probability of p__i percents. The songs could get on Manao's playlist in any order, so Manao wants to know the maximum expected value of the number of seconds after which the listening process will be over, for all possible permutations of the songs in the playlist.

玛瑙的朋友经常给他发送新歌。他从不立即收听这些歌曲,而是将它们汇总成一个播放列表。当他感觉自己的思维已经准备好接受新音乐时,他就会打开播放列表并开始收听歌曲。

当然,其中有一些歌曲玛瑙并不特别喜欢。为了从收到的歌曲中获得更多的愉悦感,他发明了如下播放列表收听流程:

  • 如果在听完某首歌曲后,玛瑙意识到自己很喜欢它,那么他会记住这首歌,并开始收听下一首尚未收听过的歌曲;
  • 如果在听完某首歌曲后,玛瑙意识到自己并不喜欢它,那么他会重新收听此前所有他喜欢过的歌曲,然后再开始收听下一首尚未收听过的歌曲。

例如,若玛瑙的播放列表中有四首歌曲 A、B、C、D(按此顺序排列),且他最终只会喜欢歌曲 A 和 C,则其实际收听顺序如下:

  1. 玛瑙收听 A,喜欢它,并将其记住;
  2. 玛瑙收听 B,不喜欢它,于是再次收听 A;
  3. 玛瑙收听 C,喜欢该歌曲,并也将其记住;
  4. 玛瑙收听 D,但不喜欢它,于是重新收听 A 和 C。

也就是说,最终玛瑙收听歌曲 A 共三次、歌曲 C 共两次,而歌曲 B 和 D 各一次。注意:一旦玛瑙某次喜欢了一首歌,他在之后的任何一次重听中都不会再不喜欢它。

玛瑙共收到了 nn 首歌曲:其中第 ii 首歌曲时长为 lil_i 秒,玛瑙喜欢它的概率为 pip_i 百分比。这些歌曲以任意顺序进入玛瑙的播放列表,因此玛瑙希望知道:在所有可能的歌曲排列顺序中,整个收听过程结束所需时间(单位:秒)的期望值所能达到的最大值。

输入格式

The first line contains a single integer n (1 ≤ n ≤ 50000). The i-th of the following n lines contains two integers, separated by a single space — l__i and p__i (15 ≤ l__i ≤ 1000, 0 ≤ p__i ≤ 100) — the length of the i-th song in seconds and the probability that Manao will like the song, in percents.

第一行包含一个整数 nn(1≤n≤500001 \leq n \leq 50000)。接下来的 nn 行中,第 ii 行包含两个整数(用单个空格分隔)——lil_i 和 pip_i(15≤li≤100015 \leq l_i \leq 1000,0≤pi≤1000 \leq p_i \leq 100),分别表示第 ii 首歌曲的长度(单位:秒)以及 Manao 喜欢该歌曲的概率(单位:百分比)。

输出格式

In a single line print a single real number — the maximum expected listening time over all permutations of songs. The answer will be considered valid if the absolute or relative error does not exceed 10 - 9.

在一行中输出一个实数——所有歌曲排列中最大的期望收听时间。若答案的绝对或相对误差不超过 10−910^{-9},则视为正确。

输入输出样例

  • 输入#1

    3
    150 20
    150 50
    100 50

    输出#1

    537.500000000
  • 输入#2

    4
    300 0
    300 50
    240 50
    360 80

    输出#2

    2121.000000000

说明/提示

Consider the first test case. If Manao listens to the songs in the order in which they were originally compiled, the mathematical expectation will be equal to 467.5 seconds. The maximum expected value is obtained by putting the first song at the end of the playlist.

Consider the second test case. The song which is 360 seconds long should be listened to first. The song 300 seconds long which Manao will dislike for sure should be put in the end.

考虑第一个测试用例。如果 Manao 按照歌曲最初编排的顺序收听,数学期望值将等于 467.5467.5 秒。通过将第一首歌置于播放列表末尾,可获得最大的期望值。

考虑第二个测试用例。时长为 360360 秒的歌曲应最先收听;而 Manao 必然会不喜欢的那首时长为 300300 秒的歌曲则应置于播放列表末尾。

输入解题思路,AI测评打分。不知道怎么写?

首页