답안 #923734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923734 2024-02-07T16:54:26 Z shahd_abbara Self Study (JOI22_ho_t2) C++17
0 / 100
448 ms 14672 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define what(x) cout << (#x) << " -> " << x << '\n';
#define endl '\n'
#define cno cout << "NO" \
                 << "\n"
#define cy cout << "YES" \
                << "\n"
#define c1 cout << "-1" << '\n'
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

const ll N = 1000005;
const ll mod = 1000000007;

ll n, m, k, l, r, q, d, x, y, z, id, ind, pointer, point, next, curr, temp;
ll mn = 2e18, mx = 0, Maxmx = 0, Ans = 0, cost = 0, prod = 1, tot = 0, sum = 0;
ll a[N], arr[N], b[N];
vector<ll> v;
string s, t;
bool ok(ll mid)
{
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {

        temp = mid;
        x = (temp + max(a[i], b[i]) - 1) / max(a[i], b[i]);
        temp -= min(min(m, x) * max(a[i], b[i]), temp);

        y = (temp + b[i] - 1) / b[i];
        ans += min(x, m) + y;
    }

    if (ans <= m * n)
        return 1;
    return 0;
}
void solve()
{
    cin >> n >> m;
    x = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> b[i];
    }

    ll lo = 1, hi = 1e18 + 10;
    while (lo < hi)
    {
        ll mid = (lo + hi + 1) / 2;

        if (ok(mid))
            lo = mid;
        else
            hi = mid - 1;
    }
    cout << lo << endl;
}
int main()
{
    IOS int testcases = 1;

    // cin >> testcases;
    while (testcases--)
    {

        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2520 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 244 ms 14624 KB Output is correct
12 Correct 245 ms 14672 KB Output is correct
13 Correct 230 ms 12644 KB Output is correct
14 Incorrect 448 ms 12628 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2416 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 122 ms 9684 KB Output is correct
10 Correct 83 ms 6652 KB Output is correct
11 Correct 61 ms 5976 KB Output is correct
12 Correct 49 ms 5888 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2244 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Incorrect 9 ms 2392 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2520 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 244 ms 14624 KB Output is correct
12 Correct 245 ms 14672 KB Output is correct
13 Correct 230 ms 12644 KB Output is correct
14 Incorrect 448 ms 12628 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2416 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 122 ms 9684 KB Output is correct
10 Correct 83 ms 6652 KB Output is correct
11 Correct 61 ms 5976 KB Output is correct
12 Correct 49 ms 5888 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2244 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Incorrect 9 ms 2392 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2520 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 244 ms 14624 KB Output is correct
12 Correct 245 ms 14672 KB Output is correct
13 Correct 230 ms 12644 KB Output is correct
14 Incorrect 448 ms 12628 KB Output isn't correct
15 Halted 0 ms 0 KB -