Submission

Status:
[PPP-SSSSSSSSSSSSSSSS]

Score: 0

User: chawinkn

Problemset: ฮีโร่และมอนสเตอร์

Language: cpp

Time: 0.002 second

Submitted On: 2025-04-01 23:02:44

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f first
#define s second

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for (auto& i : h) cin >> i;
	vector<pair<int,ll>> v(m);
	for (auto& [i,j] : v) cin >> i >> j;
	sort(v.begin(), v.end());
	for (int i = 1; i < m; i++) v[i].s += v[i-1].s;
	for (auto H : h) {
		int i=upper_bound(v.begin(), v.end(), make_pair(H, (ll)1e18))-v.begin();
		cout << v[i-1].s << "\n";
	}
	return 0;
}