Cod sursa(job #3369152)
| Utilizator | Data | 17 octombrie 2026 14:28:14 | |
|---|---|---|---|
| Problema | Litere | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("litere.in");
ofstream fout("litere.out");
int main()
{
int n,fr[26]={0};
char s[10001];
long long cnt=0;
fin>>n>>s;
for(int i=0;i<n;i++)
{
int x=s[i]-'a';
for(int j=x+1;j<26;j++)
cnt+=fr[j];
fr[x]++;
}
fout<<cnt;
return 0;
}