답안 #803534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
803534 2023-08-03T04:47:35 Z vjudge1 Self Study (JOI22_ho_t2) C++17
0 / 100
273 ms 7368 KB

#include <bits/stdc++.h>



using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 5e5 + 9 , mod = 1e9 + 7;
ll  d[N] = {} , a[N] = {}, dp[N] = {}, b[N] , c[N];

void solve(){
    ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
    cin>>n>>k;
    for(i = 1; i <= n; i++){
        cin>>a[i];
    }
    for(i = 1; i <= n; i++){
        cin>>b[i];
    }
    l = 1;
    r = 1e18;
    while(l != r){
        m = (l + r + 1) / 2;
        s = f = 0;
        for(i = 1; i <= n; i++){
            c[i] = max(a[i] , b[i]) * k;
            if(c[i] > m)
                f += (c[i] - m) / max(a[i] , b[i]);
            if(c[i] < m)
                s  += (((m - c[i]) / b[i]) + ((m - c[i]) % b[i] != 0));
        }
        if(s <= f)
            l = m;
        else
            r = m - 1;
    }
    cout<<l<<"\n";
}

int main(){

     TL;/*
     #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
     #endif*/

int t = 1;
//cin>>t;

while(t--)
     {
     solve();
     }

}
// Author : حسن

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:29:8: warning: unused variable 'q' [-Wunused-variable]
   29 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |        ^
Main.cpp:29:16: warning: unused variable 'j' [-Wunused-variable]
   29 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                ^
Main.cpp:29:26: warning: unused variable 'z' [-Wunused-variable]
   29 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                          ^
Main.cpp:29:53: warning: unused variable 'x' [-Wunused-variable]
   29 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                                     ^
Main.cpp:29:57: warning: unused variable 'y' [-Wunused-variable]
   29 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                                         ^
Main.cpp:29:61: warning: unused variable 'mn' [-Wunused-variable]
   29 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                                             ^~
Main.cpp:29:74: warning: unused variable 'mx' [-Wunused-variable]
   29 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                                                          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 146 ms 7356 KB Output is correct
12 Correct 146 ms 7352 KB Output is correct
13 Correct 132 ms 7252 KB Output is correct
14 Incorrect 273 ms 7368 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 73 ms 3852 KB Output is correct
10 Correct 52 ms 2644 KB Output is correct
11 Correct 37 ms 2096 KB Output is correct
12 Correct 30 ms 1748 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 146 ms 7356 KB Output is correct
12 Correct 146 ms 7352 KB Output is correct
13 Correct 132 ms 7252 KB Output is correct
14 Incorrect 273 ms 7368 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 73 ms 3852 KB Output is correct
10 Correct 52 ms 2644 KB Output is correct
11 Correct 37 ms 2096 KB Output is correct
12 Correct 30 ms 1748 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 146 ms 7356 KB Output is correct
12 Correct 146 ms 7352 KB Output is correct
13 Correct 132 ms 7252 KB Output is correct
14 Incorrect 273 ms 7368 KB Output isn't correct
15 Halted 0 ms 0 KB -