답안 #534284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534284 2022-03-08T03:07:35 Z Paul_Liao_1457 Self Study (JOI22_ho_t2) C++14
100 / 100
294 ms 20480 KB
// 還要更強
#include<iostream>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<math.h>
#include<cstring>
#include<stack>
#include<string.h>
#include<random>
#include<algorithm>
#include<vector>
#include <cassert>

#define ll __int128_t
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define INF (ll)(1e9)
#define pb push_back
#define F first
#define S second
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

using namespace std;

long long n,m;
ll aaa[300005],bbb[300005];
long long a[300005],b[300005];



signed main(){
    AC;
    cin>>n>>m;
    FOR(i,1,n+1){
        cin>>a[i]; aaa[i]=a[i];
    }
    FOR(i,1,n+1){
        cin>>b[i]; bbb[i]=b[i]; aaa[i]=max(a[i],b[i]);
    }
    ll l=0,r=(3e18+1),ans=0;
    while(l<r){
        ll mid=(l+r)/2,tot=0;
        FOR(i,1,n+1){
            if(aaa[i]*m<mid){
                ll tmp=mid-aaa[i]*m;
                tot+=(tmp-1)/bbb[i]+1;
            }
            else{
                ll used=(mid-1)/aaa[i]+1;
                tot-=m-used;
                //cerr<<"m="<<m<<endl;
            }
            //cout<<"m="<<m<<endl;
        }
        //cout<<"mid="<<mid<<" tot="<<tot<<endl;
        if(tot<=0){
            ans=max(ans,mid);
            l=mid+1;
        }
        else{
            r=mid;
        }
    }
    cout<<(long long)ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 185 ms 14384 KB Output is correct
12 Correct 179 ms 14316 KB Output is correct
13 Correct 171 ms 14432 KB Output is correct
14 Correct 250 ms 14464 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 220 ms 14380 KB Output is correct
17 Correct 237 ms 14336 KB Output is correct
18 Correct 174 ms 14380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 220 ms 14380 KB Output is correct
3 Correct 237 ms 14336 KB Output is correct
4 Correct 174 ms 14380 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 95 ms 8004 KB Output is correct
14 Correct 61 ms 5472 KB Output is correct
15 Correct 53 ms 4216 KB Output is correct
16 Correct 54 ms 3536 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 4 ms 460 KB Output is correct
23 Correct 4 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 185 ms 14384 KB Output is correct
12 Correct 179 ms 14316 KB Output is correct
13 Correct 171 ms 14432 KB Output is correct
14 Correct 250 ms 14464 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 95 ms 8004 KB Output is correct
24 Correct 61 ms 5472 KB Output is correct
25 Correct 53 ms 4216 KB Output is correct
26 Correct 54 ms 3536 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 320 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 4 ms 460 KB Output is correct
33 Correct 4 ms 576 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 220 ms 14380 KB Output is correct
36 Correct 237 ms 14336 KB Output is correct
37 Correct 174 ms 14380 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 4 ms 588 KB Output is correct
46 Correct 6 ms 864 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 35 ms 3720 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 6 ms 588 KB Output is correct
52 Correct 1 ms 320 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 104 ms 10052 KB Output is correct
56 Correct 62 ms 6176 KB Output is correct
57 Correct 81 ms 6204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 95 ms 8004 KB Output is correct
10 Correct 61 ms 5472 KB Output is correct
11 Correct 53 ms 4216 KB Output is correct
12 Correct 54 ms 3536 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 4 ms 460 KB Output is correct
19 Correct 4 ms 576 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 220 ms 14380 KB Output is correct
22 Correct 237 ms 14336 KB Output is correct
23 Correct 174 ms 14380 KB Output is correct
24 Correct 36 ms 3384 KB Output is correct
25 Correct 98 ms 9332 KB Output is correct
26 Correct 23 ms 2372 KB Output is correct
27 Correct 200 ms 20180 KB Output is correct
28 Correct 224 ms 20096 KB Output is correct
29 Correct 196 ms 20228 KB Output is correct
30 Correct 247 ms 20292 KB Output is correct
31 Correct 241 ms 19908 KB Output is correct
32 Correct 240 ms 15556 KB Output is correct
33 Correct 234 ms 20480 KB Output is correct
34 Correct 217 ms 15480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 185 ms 14384 KB Output is correct
12 Correct 179 ms 14316 KB Output is correct
13 Correct 171 ms 14432 KB Output is correct
14 Correct 250 ms 14464 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 95 ms 8004 KB Output is correct
24 Correct 61 ms 5472 KB Output is correct
25 Correct 53 ms 4216 KB Output is correct
26 Correct 54 ms 3536 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 320 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 4 ms 460 KB Output is correct
33 Correct 4 ms 576 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 316 KB Output is correct
36 Correct 1 ms 320 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 4 ms 588 KB Output is correct
42 Correct 6 ms 864 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 35 ms 3720 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 6 ms 588 KB Output is correct
48 Correct 1 ms 320 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 104 ms 10052 KB Output is correct
52 Correct 62 ms 6176 KB Output is correct
53 Correct 81 ms 6204 KB Output is correct
54 Correct 36 ms 3384 KB Output is correct
55 Correct 98 ms 9332 KB Output is correct
56 Correct 23 ms 2372 KB Output is correct
57 Correct 200 ms 20180 KB Output is correct
58 Correct 224 ms 20096 KB Output is correct
59 Correct 196 ms 20228 KB Output is correct
60 Correct 247 ms 20292 KB Output is correct
61 Correct 241 ms 19908 KB Output is correct
62 Correct 240 ms 15556 KB Output is correct
63 Correct 234 ms 20480 KB Output is correct
64 Correct 217 ms 15480 KB Output is correct
65 Correct 0 ms 332 KB Output is correct
66 Correct 220 ms 14380 KB Output is correct
67 Correct 237 ms 14336 KB Output is correct
68 Correct 174 ms 14380 KB Output is correct
69 Correct 28 ms 2380 KB Output is correct
70 Correct 8 ms 832 KB Output is correct
71 Correct 1 ms 460 KB Output is correct
72 Correct 37 ms 3112 KB Output is correct
73 Correct 8 ms 996 KB Output is correct
74 Correct 2 ms 332 KB Output is correct
75 Correct 219 ms 19328 KB Output is correct
76 Correct 206 ms 19396 KB Output is correct
77 Correct 210 ms 19404 KB Output is correct
78 Correct 224 ms 19408 KB Output is correct
79 Correct 269 ms 19448 KB Output is correct
80 Correct 294 ms 19484 KB Output is correct
81 Correct 222 ms 17464 KB Output is correct
82 Correct 246 ms 17484 KB Output is correct