Cod sursa(job #3133577)
Utilizator | Traian Mihai Danciu Traian_7109 | Data | 26 mai 2023 09:41:44 |
---|---|---|---|
Problema | Litere | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("litere.in");
ofstream fout("litere.out");
short frequency[30];
int main()
{
ios_base :: sync_with_stdio(false);
fin.tie(nullptr), fout.tie(nullptr);
short n;
int cnt = 0;
char c;
fin>>n;
for (short i = 1; i <= n; i++) {
fin>>c;
for (short j = c+1; j <= 'z'; j++) cnt += frequency[j-'a'];
frequency[c-'a']++;
}
fout<<cnt;
return 0;
}