# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
887551 | salmon | Let's Win the Election (JOI22_ho_t3) | C++14 | 1 ms | 2396 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;
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];
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)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |