Cod sursa(job #1934789)

Utilizator 1475369147896537415369Andrei Udriste 1475369147896537415369 Data 21 martie 2017 20:12:59
Problema Litere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <cstdio>

int N, v[27], solution, i, j, x;
char s[10001];

int main(){

    freopen("litere.in", "r", stdin);
    freopen("litere.out", "w", stdout);

    scanf("%d %s", &N, s);

    for(i = 0; i < N; i++){
        x = s[i] - 'a';
        for(j = x + 1; j <= 26; j++){
            solution += v[j];
        }v[x]++;
    }
    printf("%d", solution);

    return 0;
}