Submission
Status:
Compilation Error
Subtask/Task Score:
Score: 0
User: robgornpeunpadpairoundnigumaipadnea
Problemset: ฮีโร่และมอนสเตอร์
Language: cpp
Time: 0.000 second
Submitted On: 2025-12-07 21:39:33
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,m;cin>>n>>m;
vector<ll> hero(n);for(auto &i:hero)cin>>i;
vector<pair<ll,ll>> en(m);
for(int i=0;i<m;i++){
ll a,b;cin>>a>>b;
en[i].first = a;en[i].second=b;
}
sort(en.begin(),en.end());
vector<ll> qwe(m);
qwe[0] = en[0].second;
for(int i=1;i<m;i++){
qwe[i] = en[i].second + qwe[i-1];
}
for(auto h:hero){
auto idx = upper_bound(en.begin(),en.end(),make_pair(h,LLONG_MAX)) - en.begin()-1;
cout<<qwe[idx] << '\n';
}
}