func_code_string: #include <bits/stdc++.h>   using namespace std;   pair<long long, long long> A[55];   double pos[55][55];   bool comp(pair<long long, long long> a, pair<long long, long long> b) {     if (a.first > b.first)       return 1;     else if (a.first < b.first)       return 0;     else {       return a.second <= b.second;     }   }   bool vis[55][55];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) cin >> A[i].first;     for (int i = 1; i <= n; ++i) cin >> A[i].second;     sort(A + 1, A + n + 1, comp);     long long low = 0;     long long high = 10000000000000;     int count = 10000;     while (--count) {       long long mid = low + high;       mid /= 2.0;       for (int i = 0; i <= n; ++i) {         for (int j = 0; j <= n; ++j) {           vis[i][j] = 0;         }       }       pos[0][0] = 0;       vis[0][0] = 1;       for (int i = 1; i <= n; ++i) {         long long st = A[i].first;         int u = i - 1;         while (i <= n && A[i].first == st) ++i;         --i;         int coun = i - u;         long long sum[55];         for (int j = u + 1; j <= i; ++j) sum[j - u] = 0;         sum[0] = 0;         for (int j = u + 1; j <= i; ++j)           sum[j - u] = sum[j - u - 1] + A[j].second;         long long sum2[55];         for (int j = u + 1; j <= i; ++j) sum2[j - u] = 0;         sum2[0] = 0;         for (int j = u + 1; j <= i; ++j)           sum2[j - u] = sum2[j - u - 1] + A[j].first;         for (int j = 0; j <= u; ++j) {           for (int l = 0; l <= min(coun, j); ++l) {             if (vis[u][j] == 0) continue;             int rem = j - l + coun - l;             if (vis[i][rem] == 0) {               vis[i][rem] = 1;               pos[i][rem] = pos[u][j] - (sum[coun] - sum[l]) * mid / 1000.0 +                             (sum2[coun] - sum2[l]);             } else               pos[i][rem] = min(pos[i][rem],                                 pos[u][j] - (sum[coun] - sum[l]) * mid / 1000.0 +                                     (sum2[coun] - sum2[l]));           }         }       }       bool flag = 0;       for (int j = 0; j <= n; ++j) {         if (pos[n][j] <= 0 && vis[n][j]) {           flag = 1;         }       }       if (flag) {         high = mid;       } else {         low = mid + 1;       }     }     cout << high << endl;     return 0;   }   