QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#353110 | #4233. Reset | PetroTarnavskyi# | WA | 0ms | 3840kb | C++20 | 1.2kb | 2024-03-13 21:17:20 | 2024-03-13 21:17:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
bool check(int n, LL m, int c, const vector<PII>& a)
{
multiset<PII> cands;
FOR(i, 0, n)
{
cands.insert(MP(-a[i].S, a[i].F));
}
LL time = 0;
while(SZ(cands))
{
auto [d, t] = *cands.begin();
cands.erase(cands.begin());
d = -d;
int cnt = t / d;
if(m >= cnt)
{
time += cnt;
if(t % d != 0)
cands.insert(MP(-(t % d), t % d));
}
else
{
time += m;
time += t - m * d;
}
}
return time <= (__int128)c * m;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, c;
cin >> n >> c;
vector<PII> a(n);
FOR(i, 0, n)
cin >> a[i].F >> a[i].S;
LL l = 0, r = (LL)n * c;
while(r - l > 1)
{
LL m = (l + r) / 2;
if(check(n, m, c, a))
r = m;
else
l = m;
}
cout << r << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
3 5 17 5 5 2 15 4
output:
3
result:
ok single line: '3'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3540kb
input:
2 1345 1344 1 10 10
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'