Submission #887553

#TimeUsernameProblemLanguageResultExecution timeMemory
887553salmonLet's Win the Election (JOI22_ho_t3)C++14
0 / 100
1 ms2396 KiB
#include <bits/stdc++.h>
using namespace std;

int N;
long long int M;
long long int A[300100];
long long int B[300100];
const long long int inf = 1.5e18;

int main(){
    scanf(" %d",&N);
    scanf(" %lld",&M);

    for(int i = 0; i < N; i++){
        scanf(" %lld",&A[i]);
    }

    for(int i = 0; i < N; i++){
        scanf(" %lld",&B[i]);
    }

    long long int s = 0;
    long long int e = inf;

    while(s != e){
        long long int m = (s + e + 1)/2;

        long long int free = 0;

        for(int i = 0; i < N; i++){
            //if(B[i] > A[i]){
                free += M;
                free -= (m + B[i] - 1) / B[i];
                if(free < (-M * N) ){
                    break;
                }
            /*}
            else{
                if( (m + A[i] - 1)/A[i] >= M){
                    long long int v = max(0LL,m - A[i] * M);
                    free -= (v + B[i] - 1)/ B[i];
                }
                else{
                    free += M;
                    free -= (m + A[i] - 1)/A[i];
                }
            }*/
        }

        if(free >= 0){
            s = m;
        }
        else{
            e = m - 1;
        }
    }

    printf("%lld",s);
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf(" %lld",&M);
      |     ~~~~~^~~~~~~~~~~~
Main.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf(" %lld",&A[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
Main.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf(" %lld",&B[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...