Submission
Status:
[PPPPPPPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: sorrkub
Problemset: ฮีโร่และมอนสเตอร์
Language: cpp
Time: 0.221 second
Submitted On: 2026-02-08 22:10:45
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef pair<long long ,long long> pll; typedef pair<long long, pair<long long , long long >> plpll;
#define int long long
const int MAX = 1e18+7;
int dx[8] = {0,0,-1,1,-1,1,-1,1} , dy[8] = {1,-1,0,0,1,-1,1,-1};
#define F first
#define S second
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
void solve(){
int n,m;
cin>>n>>m;
vector<int> vec(n),qsum(m+50);
vector<pll> mon(m);
for(int i=0;i<n;i++){
cin>>vec[i];
}
for(int i=0;i<m;i++){
cin>>mon[i].F>>mon[i].S;
}
sort(mon.begin(),mon.end());
for(int i=0;i<m;i++){
qsum[i+1]=qsum[i]+mon[i].S;
}
for(auto x:vec){
pll c = {x,MAX};
auto lo = upper_bound(mon.begin(),mon.end(),c) - mon.begin();
cout<<qsum[lo]<<"\n";
}
}
signed main(){
FAST_IO
int q=1;
//cin>>q;
while(q--){
solve();
}
return 0;
}
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \| |// `.
/ \||| : |||// \
/ _||||| -:- |||||- \
| | \ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass System Test!
*/