Submission
Status:
[PPPPPPPPPPPPPPPPPPPP]
Score: 100
User: chawinkn
Problemset: ฮีโร่และมอนสเตอร์
Language: cpp
Time: 0.278 second
Submitted On: 2025-04-01 23:03:47
#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 << (i ? v[i-1].s : 0) << "\n";
}
return 0;
}