Submission
Status:
[PPPPTSSSSSSSSSSSSSSS]
Score: 0
User: Nightingale
Problemset: ฮีโร่และมอนสเตอร์
Language: cpp
Time: 1.074 second
Submitted On: 2025-03-26 21:49:33
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a;
int b;
int wherehero = 0;
cin >> a >> b;
vector<pair<int,int>> hero(a);
vector<pair<int,int>> monster(b);
unordered_map<int,int> ans;
for(int i=0;i<a;i++){
cin >> hero[i].first;
hero[i].second = i;
}
sort(hero.begin(),hero.end(),greater<pair<int,int>>());
for(int i=0;i<b;i++){
cin >> monster[i].first >> monster[i].second;
}
sort(monster.begin(),monster.end(),greater<pair<int,int>>());
for(int i=0;i<b;i++){
if(hero[wherehero].first>=monster[i].first){
for(int j=i;j<b;j++){
ans[hero[wherehero].second]+=monster[j].second;
}
wherehero++;
i--;
}
}
for(int i=0;i<a;i++){
cout << ans[i] << '\n';
}
}