func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 51;   const long long inf = (long long)1e14;   const long long real_inf = (long long)1e18;   inline long long value(const pair<long long, long long>& task, long long t) {     return task.first - t * task.second;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<pair<long long, long long>> tasks(n);     for (int i = 0; i < n; ++i) {       cin >> tasks[i].first;       tasks[i].first *= 1000;     }     for (int i = 0; i < n; ++i) {       cin >> tasks[i].second;     }     sort(tasks.begin(), tasks.end());     reverse(tasks.begin(), tasks.end());     auto ok = [&](long long t) -> bool {       long long dp[N][N][N];       for (int i = 0; i < n; ++i) {         for (int j = 0; j <= n; ++j) {           for (int k = 0; k <= n; ++k) {             dp[i][j][k] = real_inf;           }         }       }       dp[0][0][1] = value(tasks[0], t);       for (int i = 0; i < n - 1; ++i) {         for (int j = 0; j <= n; ++j) {           for (int k = 0; k <= n; ++k) {             if (dp[i][j][k] == real_inf) {               continue;             }             if (tasks[i].first == tasks[i + 1].first) {               dp[i + 1][j][k + 1] =                   min(dp[i + 1][j][k + 1], dp[i][j][k] + value(tasks[i + 1], t));               if (j > 0) {                 dp[i + 1][j - 1][k] = min(dp[i + 1][j - 1][k], dp[i][j][k]);               }             } else {               dp[i + 1][j + k][1] =                   min(dp[i + 1][j + k][1], dp[i][j][k] + value(tasks[i + 1], t));               if (j > 0 || k > 0) {                 dp[i + 1][j + k - 1][0] =                     min(dp[i + 1][j + k - 1][0], dp[i][j][k]);               }             }           }         }       }       for (int i = 0; i <= n; ++i) {         for (int j = 0; j <= n; ++j) {           if (dp[n - 1][i][j] <= 0) {             return true;           }         }       }       return false;     };     long long left = 0, right = inf, best = inf;     while (left <= right) {       long long middle = (left + right) / 2;       if (ok(middle)) {         best = middle;         right = middle - 1;       } else {         left = middle + 1;       }     }     cout << best <<   n ;     return 0;   }   