# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
819318 | tset | Olympic Bus (JOI20_ho_t4) | C++14 | 1 ms | 436 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<<50LL;
int pos = 0;
while(pas > 0)
{
int moyenneMin = pos + pas;
int nbCoursesReq = 0;
for(int iC : famille1)
{
nbCoursesReq += moyenneMin/iC;
if(moyenneMin%iC != 0)
{
nbCoursesReq++;
}
}
for(pair<int, int> iC : famille2 )
{
int moyenneA = iC.first * M;
if(moyenneA >= moyenneMin)
{
nbCoursesReq += moyenneMin/iC.first;
if(moyenneMin%iC.first != 0)
{
nbCoursesReq++;
}
}
else
{
nbCoursesReq += M;
int nouvMoyenne = moyenneMin - moyenneA;
nbCoursesReq += nouvMoyenne/iC.second;
if(nouvMoyenne%iC.second != 0)
{
nbCoursesReq++;
}
}
}
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... |