Cod sursa(job #921177)

Utilizator superman_01Avramescu Cristian superman_01 Data 20 martie 2013 20:27:09
Problema Congr Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.81 kb
#include<cstdio>
#include<vector>
#include<utility>
#include<ctime>
#include<cstdlib>

#define MAX_SIZE 600005

FILE *f=fopen("congr.in","r");
FILE *g=fopen("congr.out","w");

using namespace std;

int index[MAX_SIZE],v[MAX_SIZE];
int n,p,sum;
int left,right;

int main( void )
{
    fscanf(f,"%d",&n);
    for(int i(1); i <= 2*n - 1  ; ++i )
    {
        fscanf(f,"%d",&v[i]);
        if( i <= n )
        sum+=v[i];
        index[i]=i;
    }
    srand(time(NULL));
    while( sum % n )
    {
        left=rand()%n+1;
        right=rand()%(n-1) +1+n;
        sum=sum-v[left]+v[right];
        swap(index[left],index[right]);
        swap(v[left],v[right]);


    }
    for(int i(1); i <= n; i++)
        fprintf(g,"%d ",index[i]);
    fclose(f);
    fclose(g);
    return 0;




}