답안 #534086

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534086 2022-03-08T00:45:34 Z PixelCat Self Study (JOI22_ho_t2) C++14
62 / 100
367 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){
        __int128_t t=tar;
        __int128_t r=min(m,(t+a[i]-1)/a[i]);
        t-=r*a[i];
        if(t>0){
            d+=(t+b[i]-1)/b[i];
        }else{
            s+=m-r;
        }
    }
    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 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 0 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 4 ms 460 KB Output is correct
11 Correct 266 ms 9696 KB Output is correct
12 Correct 248 ms 9796 KB Output is correct
13 Correct 237 ms 9660 KB Output is correct
14 Correct 318 ms 9668 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 363 ms 9688 KB Output is correct
17 Correct 295 ms 9688 KB Output is correct
18 Correct 236 ms 9624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 363 ms 9688 KB Output is correct
3 Correct 295 ms 9688 KB Output is correct
4 Correct 236 ms 9624 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 0 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 1 ms 204 KB Output is correct
13 Correct 156 ms 5004 KB Output is correct
14 Correct 86 ms 3428 KB Output is correct
15 Correct 60 ms 2560 KB Output is correct
16 Correct 50 ms 2172 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 6 ms 460 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
# 결과 실행 시간 메모리 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 0 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 4 ms 460 KB Output is correct
11 Correct 266 ms 9696 KB Output is correct
12 Correct 248 ms 9796 KB Output is correct
13 Correct 237 ms 9660 KB Output is correct
14 Correct 318 ms 9668 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 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 1 ms 204 KB Output is correct
23 Correct 156 ms 5004 KB Output is correct
24 Correct 86 ms 3428 KB Output is correct
25 Correct 60 ms 2560 KB Output is correct
26 Correct 50 ms 2172 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 6 ms 460 KB Output is correct
33 Correct 5 ms 460 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 363 ms 9688 KB Output is correct
36 Correct 295 ms 9688 KB Output is correct
37 Correct 236 ms 9624 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 1 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 5 ms 460 KB Output is correct
46 Correct 8 ms 604 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 42 ms 1908 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 5 ms 460 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 0 ms 204 KB Output is correct
55 Correct 125 ms 4964 KB Output is correct
56 Correct 78 ms 3524 KB Output is correct
57 Correct 95 ms 3404 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 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 1 ms 204 KB Output is correct
9 Correct 156 ms 5004 KB Output is correct
10 Correct 86 ms 3428 KB Output is correct
11 Correct 60 ms 2560 KB Output is correct
12 Correct 50 ms 2172 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 6 ms 460 KB Output is correct
19 Correct 5 ms 460 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 363 ms 9688 KB Output is correct
22 Correct 295 ms 9688 KB Output is correct
23 Correct 236 ms 9624 KB Output is correct
24 Correct 39 ms 1740 KB Output is correct
25 Correct 112 ms 4428 KB Output is correct
26 Correct 27 ms 1312 KB Output is correct
27 Correct 241 ms 9688 KB Output is correct
28 Correct 274 ms 9652 KB Output is correct
29 Correct 244 ms 9576 KB Output is correct
30 Correct 280 ms 9704 KB Output is correct
31 Correct 238 ms 9648 KB Output is correct
32 Correct 367 ms 9688 KB Output is correct
33 Incorrect 246 ms 9636 KB Output isn't correct
34 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 0 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 4 ms 460 KB Output is correct
11 Correct 266 ms 9696 KB Output is correct
12 Correct 248 ms 9796 KB Output is correct
13 Correct 237 ms 9660 KB Output is correct
14 Correct 318 ms 9668 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 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 1 ms 204 KB Output is correct
23 Correct 156 ms 5004 KB Output is correct
24 Correct 86 ms 3428 KB Output is correct
25 Correct 60 ms 2560 KB Output is correct
26 Correct 50 ms 2172 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 6 ms 460 KB Output is correct
33 Correct 5 ms 460 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 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 5 ms 460 KB Output is correct
42 Correct 8 ms 604 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 42 ms 1908 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 5 ms 460 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 125 ms 4964 KB Output is correct
52 Correct 78 ms 3524 KB Output is correct
53 Correct 95 ms 3404 KB Output is correct
54 Correct 39 ms 1740 KB Output is correct
55 Correct 112 ms 4428 KB Output is correct
56 Correct 27 ms 1312 KB Output is correct
57 Correct 241 ms 9688 KB Output is correct
58 Correct 274 ms 9652 KB Output is correct
59 Correct 244 ms 9576 KB Output is correct
60 Correct 280 ms 9704 KB Output is correct
61 Correct 238 ms 9648 KB Output is correct
62 Correct 367 ms 9688 KB Output is correct
63 Incorrect 246 ms 9636 KB Output isn't correct
64 Halted 0 ms 0 KB -