博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #284 (Div. 2) D. Name That Tune [概率dp]
阅读量:7294 次
发布时间:2019-06-30

本文共 4379 字,大约阅读时间需要 14 分钟。

D. Name That Tune
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

It turns out that you are a great fan of rock band AC/PE. Peter learned that and started the following game: he plays the first song of the list of n songs of the group, and you have to find out the name of the song. After you tell the song name, Peter immediately plays the following song in order, and so on.

The i-th song of AC/PE has its recognizability pi. This means that if the song has not yet been recognized by you, you listen to it for exactly one more second and with probability of pi percent you recognize it and tell it's name. Otherwise you continue listening it. Note that you can only try to guess it only when it is integer number of seconds after the moment the song starts playing.

In all AC/PE songs the first words of chorus are the same as the title, so when you've heard the first ti seconds of i-th song and its chorus starts, you immediately guess its name for sure.

For example, in the song Highway To Red the chorus sounds pretty late, but the song has high recognizability. In the song Back In Blue, on the other hand, the words from the title sound close to the beginning of the song, but it's hard to name it before hearing those words. You can name both of these songs during a few more first seconds.

Determine the expected number songs of you will recognize if the game lasts for exactly T seconds (i. e. you can make the last guess on the second T, after that the game stops).

If all songs are recognized faster than in T seconds, the game stops after the last song is recognized.

Input

The first line of the input contains numbers n and T (1 ≤ n ≤ 5000, 1 ≤ T ≤ 5000), separated by a space. Next n lines contain pairs of numbers pi and ti (0 ≤ pi ≤ 100, 1 ≤ ti ≤ T). The songs are given in the same order as in Petya's list.

Output

Output a single number — the expected number of the number of songs you will recognize in T seconds. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Sample test(s)
Input
2 2 50 2 10 1
Output
1.500000000
Input
2 2 0 2 100 2
Output
1.000000000
Input
3 3 50 3 50 2 25 2
Output
1.687500000
Input
2 2 0 2 0 2
Output
1.000000000

 

感觉集齐了各种坑,萌萌哒~ 以后只能默默地给田神拎包了

2014-12-28 07:06:00 GNU C++ Accepted 483 ms 196200 KB
2014-12-28 07:01:48 GNU C++ Runtime error on test 36 93 ms 196100 KB
2014-12-28 06:54:26 GNU C++ Runtime error on test 36 109 ms 196100 KB
2014-12-28 06:49:32 GNU C++ Runtime error on test 36 93 ms 196200 KB
2014-12-28 06:46:58 GNU C++ Runtime error on test 36 93 ms 196100 KB
2014-12-28 06:44:55 GNU C++ Wrong answer on test 3 93 ms 196100 KB
2014-12-28 06:40:00 GNU C++ Wrong answer on test 3 62 ms 196100 KB
2014-12-28 06:36:34 GNU C++ Wrong answer on test 3 109 ms 196100 KB
2014-12-28 06:25:16 GNU C++ Wrong answer on test 7 62 ms 196200 KB
2014-12-28 06:20:57 GNU C++ Wrong answer on test 7 124 ms 196100 KB
2014-12-26 04:14:38 GNU C++ Time limit exceeded on test 13 1000 ms 196200 KB
2014-12-26 04:09:52 GNU C++ Time limit exceeded on test 13 1000 ms 196200 KB
2014-12-25 16:29:08 GNU C++ Wrong answer on test 6 62 ms 196200 KB
2014-12-25 16:25:22 GNU C++ Memory limit exceeded on test 1 108 ms 262100 KB
2014-12-25 16:23:15 GNU C++ Memory limit exceeded on test 1 93 ms 262100 KB 

 

 

 

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #define eps 1e-312 #define ll long long13 #define N 500514 #define M 1000515 #define mod 200716 17 using namespace std;18 19 int n,T;20 double dp[N][N];21 double ans;22 double tot;23 double p[N];24 int t[N];25 //double q[N][N];26 27 void ini()28 {29 ans=0;tot=0;30 T++;31 memset(dp,0,sizeof(dp));32 // memset(q,0,sizeof(q));33 int i;34 for(i=1;i<=n;i++){35 scanf("%lf%d",&p[i],&t[i]);36 p[i]/=100;37 }38 dp[1][0]=1.0;39 //for(i=1;i<=n;i++){40 // q[i][1]=p[i];41 // q[i][ t[i] ]=1;42 // for(j=2;j<=t[i]-1;j++){43 // q[i][j]=q[i][j-1]*(1.0-p[i]);44 // }45 // }46 }47 48 void solve()49 {50 int i,j;51 int tmin,tmax;52 tmin=1,tmax=1;53 //double tmp;54 for(i=1;i<=min(n,T);i++){55 tmin++;tmax=min(T,tmax+t[i]);56 // tmp=pow(1-p[i],t[i]-1);57 for(j=tmin;j

 

转载于:https://www.cnblogs.com/njczy2010/p/4189806.html

你可能感兴趣的文章
03、Swagger2和Springmvc整合详细记录(爬坑记录)
查看>>
Java杂记3—流程控制之条件
查看>>
CSS keylogger:攻击与防御
查看>>
我所理解的 Block
查看>>
border?
查看>>
Swift 3.1新改动
查看>>
算法初体验
查看>>
可能是目前轻量级弹幕控件中功能最强大的一款
查看>>
SpringCloud Ribbon源码探索学习
查看>>
[Redis源码阅读]redis持久化
查看>>
分布式系统开发——调度技术
查看>>
Js传递数组参数到后台controller的方式
查看>>
前端日拱一卒D9——ES6笔记之基础篇
查看>>
Qtum量子链作客第四届拉美商业科技大会
查看>>
volatile变量与普通变量的区别
查看>>
[MetalKit]34-Working-with-memory-in-Metal内存管理
查看>>
@ngrx入坑angular的schema,爽的一逼!
查看>>
教你用JS手写简单的秒表(精确到10ms,没有延迟)
查看>>
vue.js响应式原理解析与实现
查看>>
Block
查看>>