답안 #528024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528024 2022-02-19T02:41:42 Z amukkalir Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
1 ms 460 KB
#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(ret*b < a) ret++; 
    return ret; 
}

bool ok (ll x) {
    ll jum = 0; 
    for(int i=0; i<n; i++) {
        jum += updiv(x, max(a[i], b[i])); 
        assert(updiv(x, max(a[i], b[i])) > 0); 
    }
    cerr << x << " " << jum << endl; 
    return jum <= m*n;
}

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

    ll ans = 1; 
    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

*/

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scn("%lld %lld", &n, &m);
      |        ^
Main.cpp:30:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     for(int i=0; i<n; i++) scn("%lld", &a[i]);
      |                               ^
Main.cpp:31:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     for(int i=0; i<n; i++) scn("%lld", &b[i]);
      |                               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -