-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_Array_23.cpp
More file actions
72 lines (72 loc) · 1.6 KB
/
Copy path04_Array_23.cpp
File metadata and controls
72 lines (72 loc) · 1.6 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <bits/stdc++.h>
using namespace std;
int getint(string str){
int ans;
//int n=str.size();
string nochar;
nochar = str.substr(3);
ans=stoi(nochar);
return ans;
}
int getsize(string str){
stringstream s(str);
string word;
int n=0;
while(s>>word){
n++;
}
return n;
}
int main(){
int n;
//string test="TH 300";
//cout << stoi(test)
cin >> n;
cin.ignore();
int fees[n];
string details[n],countries[n];
for(int i=0;i<n;i++){
string temp;
getline(cin,details[i]);
//cin.ignore();
temp=details[i];
/*int ans;
int n=temp.size();
string nochar;
nochar = temp.substr(3,6);
ans=stoi(nochar);
return ans;*/
//cout << temp;
fees[i]=getint(temp);
//cout << fees[i] << " ";
//fees[i]=stoi(temp);
}
//cin.ignore();
for(int i=0;i<n;i++){
countries[i]=details[i].substr(0,2);
//cout << endl <<countries[i] << endl;
}
string route;
getline(cin,route);
//cin.ignore();
int size=getsize(route);
//cout << route << endl;
//cout <<size;
string routearr[size];
int cost=0;
routearr[0]=route.substr(4,2);
//cout << routearr[0];
for(int i=1;i<size;i++){
routearr[i]=route.substr(((i*7)+4),2);
//cout << routearr[i] << " ";
if(routearr[i]!=routearr[i-1]){
for(int j=0;j<n;j++){
if(routearr[i]==countries[j]){
cost+=fees[j];
}
}
}
}
cout << cost;
return 0;
}