Pagini recente » Cod sursa (job #2557632) | Cod sursa (job #124508) | Cod sursa (job #2613464) | Cod sursa (job #1180240) | Cod sursa (job #1345589)
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;
#define Nmax 600002
FILE *f = fopen ( "congr.in" , "r" );
FILE *g = fopen ( "congr.out" , "w" );
int v[Nmax], sol[Nmax];
int main(){
int N, x, y;
long long S = 0;
fscanf ( f, "%d", &N );
srand (time (NULL));
for ( int i = 1; i < 2 * N; ++i ){
fscanf ( f,"%d", &v[i] );
sol[i] = i;
if ( i <= N )
S += v[i];
}
while ( S % N ){
x = 1 + rand () % N;
y = N + 1 + rand () % (N - 1);
S = S - v[x] + v[y];
swap ( sol[x], sol[y] );
swap ( v[x], v[y] );
}
for ( int i = 1; i <= N; ++i )
fprintf ( g, "%d ", sol[i] );
return 0;
}