-
Notifications
You must be signed in to change notification settings - Fork 0
/
10295HayPoints.cpp
46 lines (39 loc) · 1.28 KB
/
10295HayPoints.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
45
46
// Vasudev Vijayaraman
// 10295 - Hay Points
// UVA login name - vasapp
// Data Structure required - maps
// Tricks - while loops and reading in data correctly
#include "stdafx.h"
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
int TestCases; // contains number of lines to read
int NumberofJobs; // contains number of jobs
int Payment; // contains how much the payment is
long long total = 0; // holds the total pay
string words; //contains job key words associated with payment
string job; // contains the job description
cin >> TestCases; // // reading in Test cases
cin >> NumberofJobs; // read in number of jobs
map<string, int> mps; // map to hold the job key words and payment
while (TestCases--) { // while loop until test cases
cin >> words; // reading in data
cin >> Payment;
mps[words] = Payment; // associating set
}
while (NumberofJobs--) { // while loop number of jobs
total = 0;
while (1) { // infinite loop until break statement
cin >> job; // reading in job description
if (job == ".") // break when you hit a fullstop
break;
else
total += mps[job]; // adding the sum and storing in total
}
cout << total << endl; // print the total
}
return 0;
}