题目链接:CodeForces 302B Eugeny and Play List
题目大意: Eugeny 喜欢听歌,他有一个播放列表,里面有n首歌,给出n和m,然后给出每首歌曲的次数ci和时间ti,接下来给出m次询问,在给出的询问时间中,Eugeny在听哪首歌曲。(歌曲列表按照顺序播放,当第i首歌听过ci遍后才听下一首歌)
解题思路:很水的一道题目,直接遍历一遍就可以了。
#include <stdio.h>
#include <string.h>
const int N = 100005;
int n, m;
long long c[N], t[N], q[N];
void solve() {
int top = 0, p = 0;
for (int i = 1; i <= n; i++) {
top += c[i] * t[i];
while (q[p] <= top) {
printf("%d\n", i);
p++;
if (p >= m) return;
}
}
}
int main () {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%lld%lld", &c[i], &t[i]);
for (int i = 0; i < m; i++)
scanf("%lld", &q[i]);
solve();
return 0;
}