Cod sursa(job #3371761)

Utilizator LucaAlxLuca Nistor LucaAlx Data 31 octombrie 2026 15:02:07
Problema Litere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.36 kb
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ifstream fin("litere.in");
    ofstream fout("litere.out");
    int n, i, nr=0;
    int f[26] = {0};
    char c[10001];
    fin>>n;
    fin>>c;
    for(i=0;i<n;i++){
        for(int j=c[i]- 'a' + 1; j<26; j++){
            nr+=f[j];
        }
        f[c[i]-'a']++;
    }
    fout<<nr;
    
    return 0;
}