Блог пользователя f.verri

Автор f.verri, история, 12 месяцев назад, По-английски

Hello. I have been trying to solve this problem for a while now and I can't find the bug that's causing the WA, I know it's probably being caused by a stupid typo, but I can't find it at all. The code is failing on test case 2

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define iter(i, l, r) for (ll i = l; i < r; i++)

bool isPossible(ll day, ll n, ll p, ll l, ll t) {
    ll tasks = ceil(float(n) / 7.0);
    ll maxTasks = min(tasks, (n - day) * 2);

    return ((n - day) * l) + (maxTasks * t) >= p;
}

int main() {
    ll numberOfTestCases;
    cin >> numberOfTestCases;

    vector<ll> toShow;

    iter (_, 0, numberOfTestCases) {
        ll n, p, l, t;
        cin >> n >> p >> l >> t;

        ll start = 0;
        ll ender = n;
        while (ender - start > 1) {
            ll mid = (start + ender) / 2;

            if (isPossible(mid, n, p, l, t)) {
                start = mid;
            } else {
                ender = mid;
            }
        }

        toShow.push_back(start);
    }

    for (ll x : toShow) {
        cout << x << "\n";
    }

    return 0;
}

Полный текст и комментарии »

  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится