Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <algorithm>
- #include <vector>
- #include <fstream>
- #include <string>
- #include <cstdlib>
- #include <random>
- #define assert_input(expr) if (!(expr)) {cout << score << endl; return 0;}
- using namespace std;
- int main(int argc, char** argv) {
- int n;
- cin >> n;
- vector<int> task_cat(n);
- for (int i = 0; i < n; i++) {
- cin >> task_cat[i];
- task_cat[i]--;
- }
- vector<double> est_time(n);
- for (int i = 0; i < n; i++) {
- cin >> est_time[i];
- }
- int m;
- cin >> m;
- vector<vector<double>> time_ratio(m, vector<double>(4));
- for (int i = 0; i < m; i++) {
- for (int j = 0; j < 4; j++) {
- cin >> time_ratio[i][j];
- }
- }
- int score = 0;
- // bool pe = false;
- auto calc_time = [&](const vector<int>& w) {
- vector<double> real_time(m);
- double total_time = 0;
- for (int i = 0; i < n; i++) {
- auto wid = w[i];
- real_time[wid] += time_ratio[wid][task_cat[i]] * est_time[i];
- total_time = max(total_time, real_time[wid]);
- }
- return total_time;
- };
- double best_time = 1e9;
- vector<int> best_distr;
- srand(123);
- for (int i = 0; i < 100000; i++) {
- vector<int> w(n);
- for (int j = 0; j < n; j++) {
- w[j] = rand() % m;
- }
- double total_time = calc_time(w);
- if (total_time < best_time) {
- best_time = total_time;
- best_distr = w;
- }
- }
- for (auto wid : best_distr) {
- cout << wid + 1 << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement