Cod sursa(job #1570927)
Utilizator | Data | 16 ianuarie 2016 22:16:07 | |
---|---|---|---|
Problema | Litere | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
#include <cstring>
using namespace std;
ifstream in("litere.in");
ofstream out("litere.out");
const int MAX_LEN = 10000;
const int SIGMA = 26;
char S[MAX_LEN + 5];
int F[SIGMA];
int main() {
int n, i, j, ans = 0;
in >> n;
in >> S + 1;
for(i = n; i; i--) {
F[S[i] - 'a']++;
for(j = S[i] - 'a' - 1; j >= 0; j--) {
ans += F[j];
}
}
out << ans << '\n';
return 0;
}