-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1043.cpp
More file actions
59 lines (58 loc) · 777 Bytes
/
1043.cpp
File metadata and controls
59 lines (58 loc) · 777 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
52
53
54
55
56
57
58
59
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
string s;
cin>>s;
long int len = s.length(),cP=0,cA=0,cT=0,ce=0,cs=0,ct=0;
int c[6]={0};
for(long int i=0;i<len;i++){
if(s[i]=='P')
c[0]++;
if(s[i]=='A')
c[1]++;
if(s[i]=='T')
c[2]++;
if(s[i]=='e')
c[3]++;
if(s[i]=='s')
c[4]++;
if(s[i]=='t')
c[5]++;
}
int cc[6];
for(int i=0;i<6;i++)
cc[i]=c[i];
sort(cc,cc+6);
int n = cc[5];
while(n!=0){
if(c[0]!=0){
cout<<"P";
c[0]--;
}
if(c[1]!=0){
cout<<"A";
c[1]--;
}
if(c[2]!=0){
cout<<"T";
c[2]--;
}
if(c[3]!=0){
cout<<"e";
c[3]--;
}
if(c[4]!=0){
cout<<"s";
c[4]--;
}
if(c[5]!=0){
cout<<"t";
c[5]--;
}
n--;
}
system("pause");
return 0;
}