답안 #534092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534092 2022-03-08T00:59:35 Z PixelCat Self Study (JOI22_ho_t2) C++14
62 / 100
242 ms 9796 KB
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define INF (ll)(9e18)
#define int __int128_t
using namespace std;
using LL=long long;
using pii=pair<int,int>;

const int MAXN=300030;
int a[MAXN];
int b[MAXN];

bool check(__int128_t n,__int128_t m,__int128_t tar){
    __int128_t s=0,d=0;
    For(i,1,n){
        if(m*a[i]>=tar){
            s+=(m*a[i]-tar)/a[i];
        }else{
            int t=tar-m*a[i];
            d+=(t+b[i]-1)/b[i];
        }
    }
    return s>=d;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // OAO
    long long n,m; cin>>n>>m;
    For(i,1,n){
        long long t; cin>>t;
        a[i]=t;
    }
    For(i,1,n){
        long long t; cin>>t;
        b[i]=t;
        a[i]=max(a[i],b[i]);
    }
    int hi=1e18+10;
    int lo=0;
    while(hi-lo>1){
        int mi=(hi+lo)/2;
        if(check(n,m,mi)) lo=mi;
        else hi=mi;
    }
    cout<<(long long)lo<<"\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 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 0 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 174 ms 9584 KB Output is correct
12 Correct 204 ms 9688 KB Output is correct
13 Correct 163 ms 9796 KB Output is correct
14 Correct 231 ms 9796 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 207 ms 9584 KB Output is correct
17 Correct 182 ms 9624 KB Output is correct
18 Correct 175 ms 9684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 207 ms 9584 KB Output is correct
3 Correct 182 ms 9624 KB Output is correct
4 Correct 175 ms 9684 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 85 ms 5004 KB Output is correct
14 Correct 59 ms 3404 KB Output is correct
15 Correct 45 ms 2656 KB Output is correct
16 Correct 36 ms 2124 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 4 ms 460 KB Output is correct
23 Correct 4 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 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 0 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 174 ms 9584 KB Output is correct
12 Correct 204 ms 9688 KB Output is correct
13 Correct 163 ms 9796 KB Output is correct
14 Correct 231 ms 9796 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 85 ms 5004 KB Output is correct
24 Correct 59 ms 3404 KB Output is correct
25 Correct 45 ms 2656 KB Output is correct
26 Correct 36 ms 2124 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 4 ms 460 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 207 ms 9584 KB Output is correct
36 Correct 182 ms 9624 KB Output is correct
37 Correct 175 ms 9684 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 6 ms 460 KB Output is correct
46 Correct 6 ms 588 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 41 ms 1868 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 3 ms 460 KB Output is correct
52 Correct 0 ms 204 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 88 ms 4876 KB Output is correct
56 Correct 73 ms 3428 KB Output is correct
57 Correct 74 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 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 85 ms 5004 KB Output is correct
10 Correct 59 ms 3404 KB Output is correct
11 Correct 45 ms 2656 KB Output is correct
12 Correct 36 ms 2124 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 4 ms 460 KB Output is correct
19 Correct 4 ms 460 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 207 ms 9584 KB Output is correct
22 Correct 182 ms 9624 KB Output is correct
23 Correct 175 ms 9684 KB Output is correct
24 Correct 39 ms 1740 KB Output is correct
25 Correct 91 ms 4488 KB Output is correct
26 Correct 25 ms 1228 KB Output is correct
27 Correct 174 ms 9572 KB Output is correct
28 Correct 195 ms 9688 KB Output is correct
29 Correct 211 ms 9684 KB Output is correct
30 Correct 197 ms 9608 KB Output is correct
31 Correct 242 ms 9604 KB Output is correct
32 Correct 205 ms 9688 KB Output is correct
33 Incorrect 185 ms 9672 KB Output isn't correct
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 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 0 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 174 ms 9584 KB Output is correct
12 Correct 204 ms 9688 KB Output is correct
13 Correct 163 ms 9796 KB Output is correct
14 Correct 231 ms 9796 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 85 ms 5004 KB Output is correct
24 Correct 59 ms 3404 KB Output is correct
25 Correct 45 ms 2656 KB Output is correct
26 Correct 36 ms 2124 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 4 ms 460 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 6 ms 460 KB Output is correct
42 Correct 6 ms 588 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 41 ms 1868 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 3 ms 460 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 88 ms 4876 KB Output is correct
52 Correct 73 ms 3428 KB Output is correct
53 Correct 74 ms 3448 KB Output is correct
54 Correct 39 ms 1740 KB Output is correct
55 Correct 91 ms 4488 KB Output is correct
56 Correct 25 ms 1228 KB Output is correct
57 Correct 174 ms 9572 KB Output is correct
58 Correct 195 ms 9688 KB Output is correct
59 Correct 211 ms 9684 KB Output is correct
60 Correct 197 ms 9608 KB Output is correct
61 Correct 242 ms 9604 KB Output is correct
62 Correct 205 ms 9688 KB Output is correct
63 Incorrect 185 ms 9672 KB Output isn't correct
64 Halted 0 ms 0 KB -