Submission
Status:
[PPPPTSSSSSSSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: FakeAnutin
Problemset: ฮีโร่และมอนสเตอร์
Language: cpp
Time: 1.014 second
Submitted On: 2026-11-20 22:46:04
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n,m; cin>>n>>m;
vector<int> vv;
map<long long,long long> mp;
map<long long,long long> pf;
int mx=0;
for(int i=1;i<=n;i++){
int k; cin>>k;
vv.push_back(k);
}
for(int i=1;i<=m;i++){
int x,y; cin>>x>>y;
mp[x]+=y;
}
int prev=0;
for(auto x : mp){
pf[x.first] = pf[prev] + x.second;
prev = x.first;
}
for(auto h : vv){
auto it = pf.upper_bound(h);
if(it == pf.begin()){
cout << 0 << '\n';
}else{
--it;
cout << it->second << '\n';
}
}
}