Cod sursa(job #553358)

Utilizator paul_gabryelPaul Buda paul_gabryel Data 13 martie 2011 22:32:03
Problema Litere Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb

#include <cstdio>
#include <fstream>

using namespace std;

int c[27],n,r;
char s[1001];
	
	void solve (){
		
		for(int i=0;s[i];++i){
			for(int j=s[i]-'a'+1;j<26;++j)
			r+=c[j];
			++c[s[i]-'a'];
			}
		
		}

int main ()
{
	
	ifstream in ("litere.in");
	in>>n;
	in.getline(s,1001);
	in.getline(s,1001);
	in.close ();
	solve ();
	freopen ("litere.out","w",stdout);
	printf("%d\n",r);
	
	return 0;}