Cod sursa(job #3371745)

Utilizator bucurmihneaBucur Mihnea David bucurmihnea Data 31 octombrie 2026 13:54:59
Problema Litere Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.37 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("litere.in");
ofstream fout("litere.out");
int main()
{
    int n;
    fin >> n;
    char s[10001];
    fin >> s;
    long long c = 0;
    for(int i = 0; i < n - 1; i++)
        for(int j = i + 1; j < n; j++)
            if(s[i] - 'a' > s[j] - 'a') c++;
    fout << c;

    return 0;
}