답안 #528055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528055 2022-02-19T05:10:34 Z amukkalir Self Study (JOI22_ho_t2) C++17
54 / 100
228 ms 7848 KB
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 

#define prn printf
#define scn scanf

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

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

bool ok (ll x) {
    unsigned long long cnt = 0;
    for(int i=0; i<n; i++) {
        cnt += updiv(x, a[i]); 
        if(cnt > n*m) return false; 
    }
    return cnt <= n*m; 
}

signed main () {
    scn("%d%d", &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 = 0; 
    ll lo = 0, 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); 
}

/*
dari 3e5 slot 
buat setiap mapel mau study berapa kali 
*/

Compilation message

Main.cpp: In function 'bool ok(ll)':
Main.cpp:22:16: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |         if(cnt > n*m) return false;
      |            ~~~~^~~~~
Main.cpp:24:16: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'll' {aka 'long long int'} [-Wsign-compare]
   24 |     return cnt <= n*m;
      |            ~~~~^~~~~~
Main.cpp: In function 'int main()':
Main.cpp:28:11: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   28 |     scn("%d%d", &n,&m);
      |          ~^     ~~
      |           |     |
      |           int*  ll* {aka long long int*}
      |          %lld
Main.cpp:28:13: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'll*' {aka 'long long int*'} [-Wformat=]
   28 |     scn("%d%d", &n,&m);
      |            ~^      ~~
      |             |      |
      |             int*   ll* {aka long long int*}
      |            %lld
Main.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scn("%d%d", &n,&m);
      |        ^
Main.cpp:29:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     for(int i=0; i<n; i++) scn("%lld", &a[i]);
      |                               ^
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", &b[i]);
      |                               ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 48 ms 2632 KB Output is correct
10 Correct 33 ms 1816 KB Output is correct
11 Correct 24 ms 1356 KB Output is correct
12 Correct 20 ms 1248 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 44 ms 4964 KB Output is correct
22 Correct 95 ms 4956 KB Output is correct
23 Correct 94 ms 4932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 48 ms 2632 KB Output is correct
10 Correct 33 ms 1816 KB Output is correct
11 Correct 24 ms 1356 KB Output is correct
12 Correct 20 ms 1248 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 44 ms 4964 KB Output is correct
22 Correct 95 ms 4956 KB Output is correct
23 Correct 94 ms 4932 KB Output is correct
24 Correct 35 ms 972 KB Output is correct
25 Correct 73 ms 3252 KB Output is correct
26 Correct 18 ms 872 KB Output is correct
27 Correct 98 ms 6692 KB Output is correct
28 Correct 100 ms 6704 KB Output is correct
29 Correct 105 ms 6680 KB Output is correct
30 Correct 124 ms 6748 KB Output is correct
31 Correct 211 ms 7848 KB Output is correct
32 Correct 127 ms 5576 KB Output is correct
33 Correct 228 ms 6580 KB Output is correct
34 Correct 124 ms 4972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -