제출 #527997

#제출 시각아이디문제언어결과실행 시간메모리
527997amukkalirSelf Study (JOI22_ho_t2)C++17
0 / 100
473 ms5064 KiB
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 

#define prn printf
#define scn scanf

ll n, m; 
const int nax = 3e5; 
ll a[nax+5], b[nax+5]; 

ll updiv(ll a, ll b) {
    ll ret = a/b; 
    if(b*ret!=a) ret++; 
    return ret; 
}

bool ok (ll x) {
    ll jum = 0; 
    for(int i=0; i<n; i++) {
        ll rem = x; 
        ll cur = 0; 
        if(a[i] > b[i]) {
            cur += min(m, updiv(x, a[i])); 
            rem -= cur*a[i]; 
        }
        if(rem > 0) {
            cur += updiv(rem, b[i]); 
        }
//cerr << i << " " << cur << endl; 
        jum += cur; 
    }
    return jum <= n*m; 
}

signed main () {
    scn("%lld %lld", &n, &m); 
    for(int i=0; i<n; i++) scn("%d", &a[i]);
    for(int i=0; i<n; i++) scn("%d", &b[i]);

    ll ans = 0; 
    ll lo = 1, hi = 1e18; 
    while(lo <= hi) {
        ll mid = (lo+hi)>>1; 
        if(ok(mid)) {
            ans = mid; 
            lo = mid+1; 
        } else hi = mid-1; 
    }
    prn("%lld", ans); 
}

/*
binser 
cek (x)
coba self study semua 
coba kalo nambahin dtg bsb erkurang ga harinya 
jumlahin harinya hrs less than or equal n*m

*/

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:38:34: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   38 |     for(int i=0; i<n; i++) scn("%d", &a[i]);
      |                                 ~^   ~~~~~
      |                                  |   |
      |                                  |   ll* {aka long long int*}
      |                                  int*
      |                                 %lld
Main.cpp:39:34: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   39 |     for(int i=0; i<n; i++) scn("%d", &b[i]);
      |                                 ~^   ~~~~~
      |                                  |   |
      |                                  |   ll* {aka long long int*}
      |                                  int*
      |                                 %lld
Main.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scn("%lld %lld", &n, &m);
      |        ^
Main.cpp:38:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     for(int i=0; i<n; i++) scn("%d", &a[i]);
      |                               ^
Main.cpp:39:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     for(int i=0; i<n; i++) scn("%d", &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...