Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. typedef long long ll;
  7. typedef unsigned long long ull;
  8. typedef unsigned int ui;
  9. typedef long double ld;
  10. typedef __int128_t sll;
  11.  
  12.  
  13.  
  14. int main()
  15. {
  16.     //ios_base::sync_with_stdio(0);
  17.     //cin.tie(0); cout.tie(0);
  18.  
  19.     string in[6];
  20.     in[0] = "tests/a_example.txt";
  21.     in[1] = "tests/b_read_on.txt";
  22.     in[2] = "tests/c_incunabula.txt";
  23.     in[3] = "tests/d_tough_choices.txt";
  24.     in[4] = "tests/e_so_many_books.txt";
  25.     in[5] = "tests/f_libraries_of_the_world.txt";
  26.  
  27.     string out[6];
  28.     out[0] = "res/a.txt";
  29.     out[1] = "res/b.txt";
  30.     out[2] = "res/c.txt";
  31.     out[3] = "res/d.txt";
  32.     out[4] = "res/e.txt";
  33.     out[5] = "res/f.txt";
  34.  
  35.     for (int test = 0; test < 6; test++) {
  36.     int B, L, D;
  37.     vector<int> score;
  38.     vector<pair<double, int>> sumlib;
  39.     vector<vector<int>> blib;
  40.     vector<bool> used;
  41.    
  42.     ifstream cin(in[test]);
  43.     ofstream cout(out[test]);
  44.  
  45.  
  46.     cin >> B >> L >> D;
  47.     score.resize(B);
  48.     used.resize(B);
  49.  
  50.     for (int i = 0; i < B; i++) {
  51.         cin >> score[i];
  52.     }
  53.  
  54.     for (int i = 0; i < L; i++) {
  55.         double N, T, M, sum = 0;
  56.         cin >> N >> T >> M;
  57.         blib.push_back({});
  58.         for (int j = 0; j < N; j++) {
  59.             int b;
  60.             cin >> b; sum += score[b];
  61.             blib[i].push_back(b);
  62.         }
  63.         sumlib.push_back({sum / (T + N/M), i});
  64.         sort(blib[i].begin(), blib[i].end(), [&](int a, int b){return score[a] > score[b];});
  65.     }
  66.     sort(sumlib.rbegin(), sumlib.rend());
  67.  
  68.     cout << L << '\n';
  69.  
  70.     for (int i = 0; i < L; i++) {
  71.         int id =  sumlib[i].second;
  72.         cout << id << ' ' << blib[id].size() << '\n';
  73.         for (int b : blib[id])
  74.             cout << b << ' ';
  75.         cout << '\n';
  76.     }
  77.     cout.close();
  78.     cin.close();
  79.     }
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement