Untitled

 avatar
user_5668965
c_cpp
a year ago
2.3 kB
7
Indexable
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(v) v.begin(), v.end()
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rep(i, m, n) for (int i = m; i < n; i++)

void __print(int x)
{
    cerr << x;
}
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

ll mod = 1000000007;

void solve()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> prefix(n + 1, 0);
    vector<ll> time(n);
    for (int i = 0; i < n; i++)
    {
        ll c, t;
        cin >> c >> t;
        time[i] = c * t;
    }
    for (int i = 1; i <= n; i++)
    {
        prefix[i] = prefix[i - 1] + time[i - 1];
    }
    for (int i = 0; i < m; i++)
    {
        ll x;
        cin >> x;
        auto it = lower_bound(all(prefix), x);
        cout << it - prefix.begin() << '\n';
    }
    //debug(prefix);
}

/*
   

*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // ll tt;
    // cin >> tt;
    // while (tt--)
    solve();
}
Editor is loading...
Leave a Comment