Codeforces Nineteen

Link: http://codeforces.com/problemset/problem/393/A

/*
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.

*/

#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back

typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, int>mpci;

const int mod = 1000007;
const int high = 100;

mpci mp;
char ch[10]={'e' , 'i' , 'n' , 't'};

class nineteen
{
    int len , i , ans=100003;

public:
    void solution(string s)
    {
        mp.clear();

        ans = 1000005;
        //ans = -1;

        len = s.length();

        for(i=0; i<len; i++)
        {
            mp[s[i]]++;
        }

        for(i=0; i<4; i++)
        {
            if(ch[i] == 'n') ans = min(ans , (mp[ch[i]]-1) / 2);
            else if(ch[i] == 'i') ans = min(ans , mp[ch[i]] / 1);
            else if(ch[i] == 't') ans = min(ans , mp[ch[i]] / 1);
            else if(ch[i] == 'e') ans = min(ans, (mp[ch[i]]) / 3);
        }

        outn(ans);
    }
};


int main()
{
    fast;
    nineteen ob;
    string s;
    while(cin >> s)
    {
        ob.solution(s);
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number