답안 #824340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824340 2023-08-14T03:20:14 Z ttamx Self Study (JOI22_ho_t2) C++14
100 / 100
242 ms 13912 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=3e5+5;

int n;
ll m;
ll a[N],b[N],ord[N];

bool check(ll val){
    ll cnt=0;
    for(int i=1;i<=n;i++){
        int id=ord[i];
        ll used=(val+a[id]-1)/a[id];
        if(used<=m){
            cnt+=m-used;
        }else{
            cnt-=(val-m*a[id]+b[id]-1)/b[id];
            if(cnt<0)return false;
        }
    }
    return true;
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> m;
    for(int i=1;i<=n;i++)cin >> a[i];
    for(int i=1;i<=n;i++)cin >> b[i];
    for(int i=1;i<=n;i++)a[i]=max(a[i],b[i]);
    iota(ord,ord+n+1,0);
    sort(ord+1,ord+n+1,[&](int x,int y){
        return a[x]>a[y];
    });
    ll l=0,r=1e18;
    while(l<r){
        ll mid=(l+r+1)/2;
        if(check(mid))l=mid;
        else r=mid-1;
    }
    cout << l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 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 212 KB Output is correct
10 Correct 3 ms 396 KB Output is correct
11 Correct 111 ms 7344 KB Output is correct
12 Correct 112 ms 7344 KB Output is correct
13 Correct 59 ms 7324 KB Output is correct
14 Correct 67 ms 7248 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 33 ms 8524 KB Output is correct
17 Correct 74 ms 13808 KB Output is correct
18 Correct 113 ms 13060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 33 ms 8524 KB Output is correct
3 Correct 74 ms 13808 KB Output is correct
4 Correct 113 ms 13060 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 62 ms 3792 KB Output is correct
14 Correct 39 ms 2600 KB Output is correct
15 Correct 28 ms 2044 KB Output is correct
16 Correct 25 ms 1728 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 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 212 KB Output is correct
10 Correct 3 ms 396 KB Output is correct
11 Correct 111 ms 7344 KB Output is correct
12 Correct 112 ms 7344 KB Output is correct
13 Correct 59 ms 7324 KB Output is correct
14 Correct 67 ms 7248 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 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 62 ms 3792 KB Output is correct
24 Correct 39 ms 2600 KB Output is correct
25 Correct 28 ms 2044 KB Output is correct
26 Correct 25 ms 1728 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 1 ms 324 KB Output is correct
35 Correct 33 ms 8524 KB Output is correct
36 Correct 74 ms 13808 KB Output is correct
37 Correct 113 ms 13060 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 0 ms 328 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 4 ms 724 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 20 ms 2456 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 58 ms 6684 KB Output is correct
56 Correct 21 ms 3924 KB Output is correct
57 Correct 21 ms 3964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 62 ms 3792 KB Output is correct
10 Correct 39 ms 2600 KB Output is correct
11 Correct 28 ms 2044 KB Output is correct
12 Correct 25 ms 1728 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 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 33 ms 8524 KB Output is correct
22 Correct 74 ms 13808 KB Output is correct
23 Correct 113 ms 13060 KB Output is correct
24 Correct 32 ms 2260 KB Output is correct
25 Correct 80 ms 5976 KB Output is correct
26 Correct 17 ms 1620 KB Output is correct
27 Correct 129 ms 13100 KB Output is correct
28 Correct 118 ms 13096 KB Output is correct
29 Correct 124 ms 13160 KB Output is correct
30 Correct 155 ms 13168 KB Output is correct
31 Correct 235 ms 13160 KB Output is correct
32 Correct 68 ms 8488 KB Output is correct
33 Correct 222 ms 13912 KB Output is correct
34 Correct 108 ms 8524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 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 212 KB Output is correct
10 Correct 3 ms 396 KB Output is correct
11 Correct 111 ms 7344 KB Output is correct
12 Correct 112 ms 7344 KB Output is correct
13 Correct 59 ms 7324 KB Output is correct
14 Correct 67 ms 7248 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 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 62 ms 3792 KB Output is correct
24 Correct 39 ms 2600 KB Output is correct
25 Correct 28 ms 2044 KB Output is correct
26 Correct 25 ms 1728 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 328 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 4 ms 724 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 20 ms 2456 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 58 ms 6684 KB Output is correct
52 Correct 21 ms 3924 KB Output is correct
53 Correct 21 ms 3964 KB Output is correct
54 Correct 32 ms 2260 KB Output is correct
55 Correct 80 ms 5976 KB Output is correct
56 Correct 17 ms 1620 KB Output is correct
57 Correct 129 ms 13100 KB Output is correct
58 Correct 118 ms 13096 KB Output is correct
59 Correct 124 ms 13160 KB Output is correct
60 Correct 155 ms 13168 KB Output is correct
61 Correct 235 ms 13160 KB Output is correct
62 Correct 68 ms 8488 KB Output is correct
63 Correct 222 ms 13912 KB Output is correct
64 Correct 108 ms 8524 KB Output is correct
65 Correct 1 ms 324 KB Output is correct
66 Correct 33 ms 8524 KB Output is correct
67 Correct 74 ms 13808 KB Output is correct
68 Correct 113 ms 13060 KB Output is correct
69 Correct 23 ms 1620 KB Output is correct
70 Correct 6 ms 560 KB Output is correct
71 Correct 0 ms 340 KB Output is correct
72 Correct 33 ms 2180 KB Output is correct
73 Correct 7 ms 712 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 122 ms 13128 KB Output is correct
76 Correct 134 ms 13368 KB Output is correct
77 Correct 150 ms 13156 KB Output is correct
78 Correct 178 ms 13160 KB Output is correct
79 Correct 232 ms 13156 KB Output is correct
80 Correct 242 ms 13060 KB Output is correct
81 Correct 200 ms 11172 KB Output is correct
82 Correct 202 ms 11168 KB Output is correct