Cod sursa(job #3154023)
Utilizator | Data | 2 octombrie 2023 18:38:48 | |
---|---|---|---|
Problema | Litere | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("litere.in");
ofstream fout("litere.out");
int f[26];
int main() {
int n, x, rasp = 0;
char c;
fin >> n;
for (int i = 0; i < n; i++) {
fin >> c;
x = c - 97;
for (int j = x + 1; j < 26; j++) {
rasp += f[j];
}
f[x]++;
}
fout << rasp;
return 0;
}