Saturday, July 19, 2014

Codeforces Round #182 (Div. 2), problem: (B) Eugeny and Play List solution

Codeforces Round #182 (Div. 2), problem: (B) Eugeny and Play List: http://codeforces.com/problemset/problem/302/B

Codeforces Round #182 (Div. 2), problem: (B) Eugeny and Play List editorial: http://codeforces.com/blog/entry/7560

Codeforces Round #182 (Div. 2), problem: (B) Eugeny and Play List solution: http://ideone.com/EYj9Zl


#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int n, m, c, t, v, k=1, st[100005], fi[100005], r, l, mid, j=0;
    scanf("%d%d", &n, &m);
    for(int i=0; i<n; i++) {
        scanf("%d%d", &c, &t);
        st[i]=k, fi[i]=st[i]+c*t-1, k=fi[i]+1;
    }
    for(int i=0; i<m; i++) {
        scanf("%d", &v);
        while((v<st[j] || v>fi[j]) && j<n) j++;
        printf("%d\n", j+1); 
    }
    return 0;
}


No comments:

Post a Comment