-
Notifications
You must be signed in to change notification settings - Fork 0
/
moneyTransfer.cpp
44 lines (33 loc) · 943 Bytes
/
moneyTransfer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
this program is written for Shopee Code League 2022 qualification round
P5. Money Transfer, successfully attempted.
Wanna Wannasin 19/03/2022
*/
#include<iostream>
#include<string>
#include<map>
int main()
{
int accountNo, orderNo;
std::map<std::string, long long int> bankBalance;
std::cin >> accountNo >> orderNo;
while(accountNo--)
{
std::string owner;
long long int netWorth;
std::cin >> owner >> netWorth;
bankBalance[owner] = netWorth;
}
while(orderNo--)
{
std::string source, destination;
long long int amount;
std::cin >> source >> destination >> amount;
if(bankBalance[source] < amount)
continue;
bankBalance[source] -= amount;
bankBalance[destination] += amount;
}
for(auto i : bankBalance)
std::cout << i.first << ' ' << i.second << std::endl;
}