QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524182 | #4233. Reset | LittleCube | WA | 1ms | 5524kb | C++17 | 1.4kb | 2024-08-19 11:49:15 | 2024-08-19 11:49:15 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pl3 tuple<ll, ll, ll>
#define pdd pair<double, double>
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
ll N, C, D[200005], T[200005];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> N >> C;
for (int i = 1; i <= N; i++)
cin >> T[i] >> D[i];
// k days: k - 1 free days + 1 complete day
auto check = [&](ll k)
{
ll remain = k * C, over = 0, total = 0;
priority_queue<pl3> pq;
for (int i = 1; i <= N; i++)
pq.push(make_tuple(D[i], T[i], k));
while (!pq.empty())
{
auto [d, t, u] = pq.top();
pq.pop();
ll use = min({u, remain, t / d});
u -= use, remain -= use, t -= use * d;
if (u == 0)
over++, total += t;
else if (remain == 0)
total += t;
else if (t > 0) // arrive at last remainder
pq.push(make_tuple(min(d, t), t, u));
}
total += max(over, C - remain);
return total <= C;
};
ll l = 1, r = (ll)1e15;
while (l < r)
{
ll mid = (l + r) / 2;
if (check(mid))
r = mid;
else
l = mid + 1;
}
cout << l - 1 << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3696kb
input:
3 5 17 5 5 2 15 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5524kb
input:
2 1345 1344 1 10 10
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3812kb
input:
1 1000000000 1000000000 1
output:
477272609419088
result:
wrong answer 1st lines differ - expected: '0', found: '477272609419088'