Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef pair<long long,long long> pii;
  4. int n, l, k;
  5. double t[2][50001];
  6. double v[2][50001];
  7. bool done[2][50001];
  8. map< double, pii > res;
  9.  
  10. #define x first
  11. #define y second
  12. int main()
  13. {
  14.  
  15.     ios::sync_with_stdio(0);
  16.     cin.tie(0);
  17.  
  18.     cin >> n >> l >> k;
  19.     for(int i = 0; i < n; i++) {
  20.         cin >> t[0][i] >> v[0][i];
  21.     }
  22.     for(int i = 0; i < n; i++) {
  23.         cin >> t[1][i] >> v[1][i];
  24.     }
  25.  
  26.     for(int x = 0; x < n; x++) {
  27.         for(int y = 0; y < n; y++) {
  28.             double f1 = max(v[0][x], t[0][x]) / (v[0][x] + v[1][y]) * min(v[0][x], t[0][x]);
  29.             double f2 = max(v[1][y], t[1][y]) / (v[0][x] + v[1][y]) * min(v[1][y], t[1][y]);
  30.             double f3 = (double)l / (v[0][x] + v[1][y]);
  31.  
  32.             double t = f1 + f2 + f3;
  33.  
  34.             res[t] = {x, y};
  35.         }
  36.     }
  37.  
  38.     int ctr = 0;
  39.     for(auto it = res.begin(); it != res.end() && ctr < k; it++) {
  40.         if(done[0][ (*it).second.x ] || done[1][ (*it).second.y ]) continue;
  41.         cout << (*it).second.x+1 << " " << (*it).second.y+1 << "\n";
  42.         done[0][ (*it).second.x ] = 1;
  43.         done[1][ (*it).second.y ] = 1;
  44.         ctr++;
  45.     }
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement