Cod sursa(job #3147157)

Utilizator DariusM17Murgoci Darius DariusM17 Data 24 august 2023 13:01:58
Problema Congr Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.83 kb
//#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const string file = "congr";
ifstream cin(file + ".in");
ofstream cout(file + ".out");
#define FAST ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0) ;
int n, x;
long long sum; 
vector <pair<int,int>> a, b;
int main(void)
{
    srand(time(0));
    cin >> n;
    for (int i = 1; i <= 2 * n - 1; ++i) {
        cin >> x;
        if (i <= n) {
            a.push_back({ x ,i });
            sum += x % n;
        }
        else b.push_back({ x ,i });
    }
    while (sum%n != 0) {
        int st = rand() % n, dr = rand() % (n - 1);
        sum = (sum - a[st].first % n + b[dr].first % n + n) % n;
        swap(a[st], b[dr]);
    }
    for (auto it : a) cout << it.second << " ";
    return 0;
}