Submission #819384

#TimeUsernameProblemLanguageResultExecution timeMemory
819384tsetSelf Study (JOI22_ho_t2)C++14
100 / 100
226 ms17116 KiB
#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)

Main.cpp: In function 'int main()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%lld%lld", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld", &Ai[ai]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld", &Bi[bi]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...