-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem 22.cpp
59 lines (52 loc) · 1.11 KB
/
Problem 22.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
47
48
49
50
51
52
53
54
55
56
57
58
59
//ANSWER IS 871198282
#include<bits/stdc++.h>
using namespace std;
int main()
{
ifstream fi("names.txt");
string str2[5500],str="";
char ch;
int i=0;
while(!fi.eof())
{
fi>>ch;
if(ch!='"'&&ch!=',')
str+=ch;
else if(ch==',')
{
str2[i]=str;
str="";
i++;
}
}
str2[i]="ALONSO";
i++;
for(int x=0;x<i;x++)
{
for(int y=0;y<x;y++)
{
if(str2[x].compare(str2[y])==-1)
{
string temp = str2[y];
str2[y]=str2[x];
str2[x]=temp;
}
}
}
for(int t=0;t<i;t++)
{
cout<<str2[t]<<" ";
}
long long ans=0;
for(int k=0;k<i;k++)
{
string qwe=str2[k];
long calc=0;
for(int h=0;h<qwe.length();h++)
calc+=qwe[h]-64;
calc*=(k+1);
ans+=calc;
}
cout<<str2[i]<<"\n";
cout<<"\n\n\n"<<i<<" "<<ans;
}