Cod sursa(job #3369162)

Utilizator AndreiMstAndrei AndreiMst Data 17 octombrie 2026 14:51:46
Problema Litere Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream>

using namespace std;

int main()
{
    ifstream f("litere.in");
    ofstream g("litere.out");
    int n, fr[26] = {}, c;
    long long int s = 0;
    f >> n;
    for(int i = 0; i < n; i++)
    {
        f >> c;
        int x = c -'a';

        for(int j = x + 1; j < 26; j++)
            s += fr[j];
        fr[x]++;
    }
    g << s;
    return 0;
}