-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP5.cpp
More file actions
53 lines (50 loc) · 1.09 KB
/
Copy pathP5.cpp
File metadata and controls
53 lines (50 loc) · 1.09 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
#include <bits/stdc++.h>
using namespace std;
int sum(string array, int size){
int sum = 0;
for (int i=0; i < size; i++){
sum = sum + int(array[i] - '0');
}
return sum;
}
int main() {
int n;
cin >> n;
int count = 0;
vector<string> v;
for(int x = 0; x < n; x++){
string temp;
cin >> temp;
v.push_back(temp);
}
vector<pair<int, int>> p;
for (int i=0;i<n;i++){
int len = v[i].size();
p.push_back(make_pair(len, sum(v[i], len)));
if ((v[i].size() == 6) && sum(v[i], len) == 25){
count++;
}
}
sort(p.begin(), p.end());
int a = 0;
int b = n-1;
while(a < b){
int sum = p[a].first + p[b].first;
if(sum == 12){
if(p[a].second + p[b].second == 50){
count++;
count++;
}
a++;
b--;
}
else if(sum < 12){
a++;
}
else{
b--;
}
}
cout<<count;
return 0;
}