Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef pair<long long,long long> pii;
- int n, l, k;
- double t[2][50001];
- double v[2][50001];
- bool done[2][50001];
- map< double, pii > res;
- #define x first
- #define y second
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cin >> n >> l >> k;
- for(int i = 0; i < n; i++) {
- cin >> t[0][i] >> v[0][i];
- }
- for(int i = 0; i < n; i++) {
- cin >> t[1][i] >> v[1][i];
- }
- for(int x = 0; x < n; x++) {
- for(int y = 0; y < n; y++) {
- double f1 = max(v[0][x], t[0][x]) / (v[0][x] + v[1][y]) * min(v[0][x], t[0][x]);
- double f2 = max(v[1][y], t[1][y]) / (v[0][x] + v[1][y]) * min(v[1][y], t[1][y]);
- double f3 = (double)l / (v[0][x] + v[1][y]);
- double t = f1 + f2 + f3;
- res[t] = {x, y};
- }
- }
- int ctr = 0;
- for(auto it = res.begin(); it != res.end() && ctr < k; it++) {
- if(done[0][ (*it).second.x ] || done[1][ (*it).second.y ]) continue;
- cout << (*it).second.x+1 << " " << (*it).second.y+1 << "\n";
- done[0][ (*it).second.x ] = 1;
- done[1][ (*it).second.y ] = 1;
- ctr++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement