Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define FOR(i,a,b) for (int i = (a); i < (b); i++)
- #define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
- #define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
- #define FILL(a,value) memset(a, value, sizeof(a))
- #define SZ(a) (int)a.size()
- #define ALL(a) a.begin(), a.end()
- #define PB push_back
- #define MP make_pair
- typedef long long LL;
- typedef vector<int> VI;
- typedef pair<int, int> PII;
- const double PI = acos(-1.0);
- const int INF = 1000 * 1000 * 1000 + 7;
- const LL LINF = INF * (LL) INF;
- const int MAX = 3030;
- double P[3][MAX];
- int n;
- bool U[MAX];
- bool W[MAX];
- int findMax()
- {
- pair<double, int> mx = MP(-1e47, -INF);
- FOR (i, 0, n * 3)
- {
- if (U[i]) continue;
- mx = max(mx, MP(P[2][i], i));
- }
- return mx.second;
- }
- int main()
- {
- freopen("in.txt", "r", stdin);
- //ios::sync_with_stdio(false); cin.tie(0);
- cin>>n;
- FOR (i, 0, 3)
- {
- FOR (j, 0, n * 3)
- {
- cin>>P[i][j];
- }
- }
- double sum = 0;
- FOR (j, 0, n * 3)
- {
- sum += P[1][j];
- P[2][j] -= P[1][j];
- }
- FOR (j, 0, n)
- {
- int ind = findMax();
- U[ind] = true;
- sum += P[2][ind];
- }
- sum = -sum;
- FOR (it, 0, n)
- {
- int ind = findMax();
- pair<double, int> mx = MP(-1e47, -INF);
- FOR (i, 0, n * 3)
- {
- if (W[i]) continue;
- double cur = P[0][i] * 2 + P[1][i];
- if (U[i])
- {
- cur += P[2][i];
- cur -= P[2][ind];
- }
- mx = max(mx, MP(cur, i));
- }
- sum += mx.first;
- W[mx.second] = true;
- if (U[mx.second]) U[ind] = true;
- }
- sum /= 3;
- printf("%.11f\n", sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement