A9037 | Eugeny and Play List
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Eugeny loves listening to music. He has $n$ songs in his play list. We know that song number $i$ has the duration of $t_{i}$ minutes. Eugeny listens to each song, perhaps more than once. He listens to song number $i$ $c_{i}$ times. Eugeny's play list is organized as follows: first song number $1$ plays $c_{1}$ times, then song number $2$ plays $c_{2}$ times, $...$ , in the end the song number $n$ plays $c_{n}$ times.
Eugeny took a piece of paper and wrote out $m$ moments of time when he liked a song. Now for each such moment he wants to know the number of the song that played at that moment. The moment $x$ means that Eugeny wants to know which song was playing during the $x$ -th minute of his listening to the play list.
Help Eugeny and calculate the required numbers of songs.
Eugeny took a piece of paper and wrote out $m$ moments of time when he liked a song. Now for each such moment he wants to know the number of the song that played at that moment. The moment $x$ means that Eugeny wants to know which song was playing during the $x$ -th minute of his listening to the play list.
Help Eugeny and calculate the required numbers of songs.
输入格式
The first line contains two integers $n$ , $m$ $(1<=n,m<=10^{5})$ . The next $n$ lines contain pairs of integers. The $i$ -th line contains integers $c_{i},t_{i}$ $(1<=c_{i},t_{i}<=10^{9})$ — the description of the play list. It is guaranteed that the play list's total duration doesn't exceed $10^{9}$ .
The next line contains $m$ positive integers $v_{1},v_{2},...,v_{m}$ , that describe the moments Eugeny has written out. It is guaranteed that there isn't such moment of time $v_{i}$ , when the music doesn't play any longer. It is guaranteed that $v_{i}<v_{i+1}$ $(i<m)$ .
The moment of time $v_{i}$ means that Eugeny wants to know which song was playing during the $v_{i}$ -th munite from the start of listening to the playlist.
The next line contains $m$ positive integers $v_{1},v_{2},...,v_{m}$ , that describe the moments Eugeny has written out. It is guaranteed that there isn't such moment of time $v_{i}$ , when the music doesn't play any longer. It is guaranteed that $v_{i}<v_{i+1}$ $(i<m)$ .
The moment of time $v_{i}$ means that Eugeny wants to know which song was playing during the $v_{i}$ -th munite from the start of listening to the playlist.
输出格式
Print $m$ integers — the $i$ -th number must equal the number of the song that was playing during the $v_{i}$ -th minute after Eugeny started listening to the play list.
输入输出样例
输入 #1
1 2 2 8 1 16
输出 #1
1 1
输入 #2
4 9 1 2 2 1 1 1 2 2 1 2 3 4 5 6 7 8 9
输出 #2
1 1 2 2 3 4 4 4 4
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted