Submission #819318

#TimeUsernameProblemLanguageResultExecution timeMemory
819318tsetOlympic Bus (JOI20_ho_t4)C++14
0 / 100
1 ms436 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<<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)

ho_t4.cpp: In function 'int main()':
ho_t4.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);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
ho_t4.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]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
ho_t4.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...