Cod sursa(job #3371555)

Utilizator mari_the_dinosaurDumitrescu Maria mari_the_dinosaur Data 30 octombrie 2026 19:13:54
Problema Litere Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("intrare.in");
ofstream fout("intrare.out");
int main()
{
	int n, i, j, v[100] = {0}, ct = 0;
	char c;
	fin >> n;
	for (i = 0; i < n; i++) {
	    fin >> c;
	    int poz = c - 'a';
	    for (j = poz + 1; j < 26; j ++) {
	        ct += v[j];
	    }
	    v[poz] ++;
	}
	fout << ct;

	return 0;
}