Please read the new rule regarding the restriction on the use of AI tools. ×
Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Need help on 1902-Getting Points

Revision en1, by f.verri, 2023-12-08 18:04:06

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;
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English f.verri 2023-12-08 18:04:06 1263 Initial revision (published)