# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
819384 | tset | Self Study (JOI22_ho_t2) | C++14 | 226 ms | 17116 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int N, M;
scanf("%lld%lld", &N, &M);
vector<int> Ai(N), Bi(N);
for(int ai = 0; ai < N; ai++)
{
scanf("%lld", &Ai[ai]);
}
for(int bi = 0; bi< N; bi++)
{
scanf("%lld", &Bi[bi]);
}
vector<int> famille1;
vector<pair<int, int>> famille2;
for(int iN = 0; iN < N; iN++)
{
if(Bi[iN] >= Ai[iN])
{
famille1.push_back(Bi[iN]);
}
else
{
famille2.push_back({Ai[iN], Bi[iN]});
}
}
int pas = 1LL<<60LL;
int pos = 0;
while(pas > 0)
{
int ptsMin = pos + pas;
if(ptsMin > 1LL<<60LL)
{
pas/=2;
continue;
}
int nbCoursesReq = 0;
for(int iC : famille1)
{
nbCoursesReq += (ptsMin+iC-1)/iC;
if(nbCoursesReq > N*M)
{
break;
}
}
for(pair<int, int> iC : famille2 )
{
int ptsA = iC.first * M;
if(ptsA >= ptsMin)
{
nbCoursesReq += (ptsMin + iC.first-1)/iC.first;
}
else
{
nbCoursesReq += M;
int ptsRest = ptsMin - ptsA;
nbCoursesReq += (ptsRest+iC.second-1)/iC.second;
}
if(nbCoursesReq > N*M)
{
break;
}
}
if(nbCoursesReq <= M * N)
{
pos += pas;
}
pas/= 2;
}
printf("%lld\n", pos);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |