MOST VALUABLE PLAYER- Editorial || MVP

PROBLEM LINK: MOST VALUABLE PLAYER | CodeChef

Problem Code: MOST VALUABLE PLAYER | CodeChef

Practice: CodeChef | Competitive Programming | Participate & Learn | CodeChef

Contest : Campus Code Coding Competition | CodeChef

Author: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
Tester: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
Editorialist: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9

DIFFICULTY:

Easy

PREREQUISITES:

Looping & Compairing

PROBLEM:

You host a PUBG Game. Killing an enemy gives you 50 points, reviving your teammate gives you 100 points, assisting a kill gives 30 points, and gathering loot gives 10 points. given the event table of a player in form of an array of events finds the MVP for the game.

EXPLANATION:
Loop through each players event table. Compare and add their score.

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

int main() {
// your code goes here
long long int n,i=0;
cin>>n;
map<string,int>m;
priority_queue<pair<int,string>>q;
m[“KILL”]=50;
m[“REVIVE”]=100;
m[“ASSIST”]=30;
m[“LOOT”]=10;
string s;
while(i<n)
{
string ss;
cin>>ss;
if(ss==“LOOT” or ss==“KILL” or ss==“REVIVE” or ss==“ASSIST”)
{
m[s]+=m[ss];
q.push({m[s],s});
}
else
{
s=ss;
i++;
}
}

    auto p=q.top();
    cout<<p.second<<endl;
return 0;

}