Submission
Status:
[PPPPPPPPPPPPPPPPPPPP]
Score: 100
User: achinhchin
Problemset: ฮีโร่และมอนสเตอร์
Language: cpp
Time: 0.296 second
Submitted On: 2025-04-01 19:08:37
#include <algorithm>
#include <climits>
#include <iostream>
#include <utility>
#include <vector>
#define f first
#define s second
using namespace std;
typedef long long l;
l h,m,a,b,i;
vector<l> H;
vector<pair<l,l> > M;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin>>h>>m; while(h--)cin>>a,H.push_back(a);
M.emplace_back(0,0);while(m--)cin>>a>>b,M.emplace_back(a,b);
sort(M.begin(),M.end()),a=0;for(;i<M.size();i++)a=M[i].s+=a;
for(auto i:H)cout<<(*--upper_bound(M.begin(),M.end(),make_pair(i,LONG_LONG_MAX))).s<<'\n';
}