Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : _example
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 06 March 2023 [19:47]
- */
- #include<bits/stdc++.h>
- using namespace std;
- pair<int ,int > a[100010];
- int b[100010];
- int main(){
- cin.tie(0)->sync_with_stdio(0);
- cin.exceptions(cin.failbit);
- int n,q;
- cin >> n >> q;
- for(int i=1;i<=n;i++)
- cin >> a[i].first >> a[i].second;
- sort(a+1,a+n+1);
- for(int i=1;i<=n;i++){
- a[i].second+=a[i-1].second;
- b[i] = a[i].second;
- }
- while(q--){
- int idx;
- cin >> idx;
- int pos = lower_bound(b+1,b+n+1,idx)-b;
- cout << a[pos].first << '\n';
- }
- return 0;
- }
- /*
- (3,4), (4,2), (10,2)
- (3,4), (4,6), (10,8)
- 1 2 3
- */
Advertisement
Add Comment
Please, Sign In to add comment