-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path22.cpp
More file actions
51 lines (37 loc) · 702 Bytes
/
Copy path22.cpp
File metadata and controls
51 lines (37 loc) · 702 Bytes
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
string plain;
cin >> plain;
stack<char> s;
string tmp = "";
vector<string> names;
for(auto c : plain) {
if(c == '\"') {
if(!s.empty() && s.top() == c) {
names.push_back(tmp);
tmp = "";
s.pop();
} else {
s.push(c);
}
} else {
if(!s.empty()) {
tmp += c;
}
}
}
sort(names.begin(), names.end());
ll ans = 0;
for(int i = 0; i < names.size(); i++) {
int score = 0;
for(auto c : names[i]) {
score += ((int)c - 64);
}
score *= (i + 1);
ans += (ll)score;
}
cout << ans;
return 0;
}