Submission #887545

# Submission time Handle Problem Language Result Execution time Memory
887545 2023-12-14T17:48:02 Z salmon Self Study (JOI22_ho_t2) C++14
0 / 100
446 ms 11036 KB
#include <bits/stdc++.h>
using namespace std;

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

int main(){
    scanf(" %d",&N);
    scanf(" %d",&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];
            }
            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

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(" %d",&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 time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2612 KB Output is correct
11 Correct 200 ms 11036 KB Output is correct
12 Correct 201 ms 10848 KB Output is correct
13 Correct 146 ms 8916 KB Output is correct
14 Incorrect 446 ms 8924 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 113 ms 7596 KB Output is correct
10 Correct 74 ms 6624 KB Output is correct
11 Correct 55 ms 6152 KB Output is correct
12 Correct 45 ms 5724 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Incorrect 9 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2612 KB Output is correct
11 Correct 200 ms 11036 KB Output is correct
12 Correct 201 ms 10848 KB Output is correct
13 Correct 146 ms 8916 KB Output is correct
14 Incorrect 446 ms 8924 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 113 ms 7596 KB Output is correct
10 Correct 74 ms 6624 KB Output is correct
11 Correct 55 ms 6152 KB Output is correct
12 Correct 45 ms 5724 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Incorrect 9 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2612 KB Output is correct
11 Correct 200 ms 11036 KB Output is correct
12 Correct 201 ms 10848 KB Output is correct
13 Correct 146 ms 8916 KB Output is correct
14 Incorrect 446 ms 8924 KB Output isn't correct
15 Halted 0 ms 0 KB -