Cod sursa(job #2433811)

Utilizator Ionut28Porumb Palincas Ionut Ionut28 Data 29 iunie 2019 11:12:14
Problema Litere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("litere.in");
ofstream fout("litere.out");
const int nmax = 10001;
int  n, fr[305], sol;
int main()
{
    fin >> n;
    char s;
    for(int i = 1; i <= n; ++i)
    {
        fin >> s;
        fr[s]++;
        for(int j = s + 1; j <= 'z'; ++j)
            sol += fr[j];
    }
    fout << sol;
    return 0;
}