Cod sursa(job #800916)

Utilizator ChallengeMurtaza Alexandru Challenge Data 22 octombrie 2012 21:36:28
Problema Congr Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
/*
	PROB: congr
	LANG: C++
*/

#include <fstream>
#include <iostream>
#include <cstdlib>
#include <ctime>

#define DEBUG

#ifndef DEBUG
	#define PRINT(x)
	#define D if(0)
#else
	#define PRINT(x) \
		cout<<#x<<":\t"<<x<<endl
	#define D if(1)
#endif

using namespace std;

const char InFile[]="congr.in";
const char OutFile[]="congr.out";
const int MaxN=600111;

ifstream fin(InFile);
ofstream fout(OutFile);

int N,V[MaxN],P[MaxN];
long long S;

int main()
{
	srand((unsigned int)(time(NULL)));

	fin>>N;
	for(register int i=1;i<2*N;++i)
	{
		fin>>V[i];
		P[i]=i;
	}
	fin.close();
	
	for(register int i=1;i<=N;++i)
	{
		S+=V[i];
	}

	while(S%N)
	{
		int x=1+rand()%N;
		int y=N+1+rand()%(N-1);
		S-=V[P[x]];
		S+=V[P[y]];
		int t=P[x];
		P[x]=P[y];
		P[y]=t;
	}

	for(register int i=1;i<=N;++i)
	{
		fout<<P[i]<<" ";
	}
	fout.close();
	return 0;
}