Cod sursa(job #3135056)
Utilizator | Prof Info profinfo114 | Data | 1 iunie 2023 18:07:59 |
---|---|---|---|
Problema | Litere | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const string fisier = "litere";
ifstream fin (fisier + ".in");
ofstream fout (fisier + ".out");
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n; fin >> n;
long long ans = 0;
int f[1005];
memset(f, 0, sizeof(f));
for (int i = 0; i < n; i++){
char x; fin >> x;
for (char ch = x + 1; ch <= 'z'; ++ch){
ans += f[ch];
}
f[x]++;
}
fout << ans;
}