hiho week 165 register

Ended

Participants:334

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-26 20:11:21

Lang:G++

Edit
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
#include <iostream>
#include <string>
using namespace std;
int cnt[26] = {0};
bool isValid(int n)
{
    for(int i = 0; i < 26; ++i)
    {
        if(cnt[i] > (n - 1) / 2 + 1)
        {
            return false;
        }
    }
    
    return true;
}
int main()
{
    string s;
    cin >> s;
    
    int N = s.length();
    
    for(int i = 0; i < N; ++i)
    {
        ++cnt[s[i] - 'a'];
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX