Submission

Status:

[PPPPTSSSSSSSSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: konthaina_TH

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

Language: cpp

Time: 1.094 second

Submitted On: 2026-03-05 20:06:49

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    cin >> n >> m;
    vector<ll> hero(n);
    for (ll i=0;i<n;i++) {
        cin >> hero[i];
    }
    vector<vector<ll>>monster(m,vector<ll>(2));
    for (ll i=0;i<m;i++) {
        for (ll j=0;j<2;j++) {
            cin >> monster[i][j];
        }
    }
    vector<ll>ans(n,0);
    sort(monster.begin(),monster.end());
    for (int i=0;i<n;i++) {
        for (ll j=0;j<m;j++) {
            if (hero[i] >= monster[j][0]) {
                ans[i] += monster[j][1];
            }
        }
    }
    for (ll x : ans) {
        cout << x << "\n";
    }
}