-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1902B.cpp
More file actions
30 lines (26 loc) · 687 Bytes
/
Copy path1902B.cpp
File metadata and controls
30 lines (26 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int test_cases;
cin >> test_cases;
while (test_cases--) {
ll n, p, l, t;
cin >> n >> p >> l >> t;
ll cntTasks = (n + 6) / 7; // ceil(n / 7)
// Function to calculate total points earned in 'k' days
auto calc = [&](ll k) -> ll {
return k * l + min(2 * k, cntTasks) * t;
};
ll lf = 0, rg = n;
while (rg - lf > 1) {
ll mid = (lf + rg) / 2;
if (calc(mid) >= p)
rg = mid;
else
lf = mid;
}
cout << n - rg << '\n';
}
return 0;
}