Submission #534786

# Submission time Handle Problem Language Result Execution time Memory
534786 2022-03-09T01:26:27 Z nathanlee726 Self Study (JOI22_ho_t2) C++14
100 / 100
277 ms 19792 KB
//#include<i_am_noob_orz>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define int ll
#define ull unsigned long long
#define pii pair<int,int>
#define X first
#define Y second
#define mod ((ll)1e9+7)
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define bit_count(x) __builtin_popcountll((x))
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define jimmy_is_kind false
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;

//#define LOCAL
#ifdef LOCAL
#define bug(...) cerr<<"#"<<__LINE__<<' '<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define IOS() ios_base::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define bug(...)
#endif

int add(int a,int b){return(a+b>=mod?a+b-mod:a+b);}
int sub(int a,int b){return(a<b?a+mod-b:a-b);}
int po(int a,int b){
	if(b==0)return 1;
	if(b==1)return(a%mod);
	int tem=po(a,b/2);
	if(b&1)return(((tem*tem)%mod)*a)%mod;
	else return(tem*tem)%mod;
}
int GCD(int a,int b){
	int x=0;
	int ra,rb;
	while(a&&b){
		if(((a&1)==0)&&((b&1)==0)){
			a>>=1,b>>=1,x++;
		}
		else if((a^b)&1){
			if(a&1)b>>=1;
			else a>>=1;
		}
		else{
			ra=abs(a-b),rb=min(a,b);
			a=ra,b=rb;
		}
	}
	return max(a,b)<<x;
}
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

int n,m,a[300010],b[300010];
vector<pii> v;

bool cmp(pii a,pii b){return a.X>b.X;}

signed main(){
	IOS();
	cin>>n>>m;
	F(n)cin>>a[i];
	F(n)cin>>b[i];
	F(n)if(a[i]<b[i])a[i]=b[i];
	int l=0,r=1e18;
	F(n)v.pb({a[i],b[i]});
	sort(all(v),cmp);
	while(l<r){
        int mi=((l+r)/2)+1;
        bool flag=1;
        int cnt=0;
        F(n){
            int x=ceiling(mi,v[i].X);
            if(x>m){
                int ss=mi;
                ss-=m*v[i].X;
                int xx=ceiling(ss,v[i].Y);
                if(xx>cnt){flag=0;break;}
                else{
                    cnt-=xx;
                }
            }
            else{
                cnt+=(m-x);
            }
        }
        if(flag)l=mi;
        else r=mi-1;
        bug(l,r);
	}
	cout<<l<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 204 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 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 588 KB Output is correct
11 Correct 141 ms 19000 KB Output is correct
12 Correct 139 ms 18996 KB Output is correct
13 Correct 110 ms 17172 KB Output is correct
14 Correct 97 ms 17128 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 48 ms 14516 KB Output is correct
17 Correct 129 ms 19792 KB Output is correct
18 Correct 141 ms 19136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 48 ms 14516 KB Output is correct
3 Correct 129 ms 19792 KB Output is correct
4 Correct 141 ms 19136 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 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 1 ms 204 KB Output is correct
13 Correct 73 ms 9672 KB Output is correct
14 Correct 50 ms 6064 KB Output is correct
15 Correct 39 ms 5068 KB Output is correct
16 Correct 32 ms 3552 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 252 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 1 ms 588 KB Output is correct
23 Correct 3 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 204 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 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 588 KB Output is correct
11 Correct 141 ms 19000 KB Output is correct
12 Correct 139 ms 18996 KB Output is correct
13 Correct 110 ms 17172 KB Output is correct
14 Correct 97 ms 17128 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 1 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 1 ms 204 KB Output is correct
23 Correct 73 ms 9672 KB Output is correct
24 Correct 50 ms 6064 KB Output is correct
25 Correct 39 ms 5068 KB Output is correct
26 Correct 32 ms 3552 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 252 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 1 ms 588 KB Output is correct
33 Correct 3 ms 564 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 48 ms 14516 KB Output is correct
36 Correct 129 ms 19792 KB Output is correct
37 Correct 141 ms 19136 KB Output is correct
38 Correct 1 ms 316 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 316 KB Output is correct
45 Correct 4 ms 716 KB Output is correct
46 Correct 5 ms 972 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 24 ms 3300 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 78 ms 9664 KB Output is correct
56 Correct 34 ms 5216 KB Output is correct
57 Correct 30 ms 5312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 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 1 ms 204 KB Output is correct
9 Correct 73 ms 9672 KB Output is correct
10 Correct 50 ms 6064 KB Output is correct
11 Correct 39 ms 5068 KB Output is correct
12 Correct 32 ms 3552 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 252 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 3 ms 564 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 48 ms 14516 KB Output is correct
22 Correct 129 ms 19792 KB Output is correct
23 Correct 141 ms 19136 KB Output is correct
24 Correct 38 ms 3020 KB Output is correct
25 Correct 95 ms 9140 KB Output is correct
26 Correct 17 ms 2020 KB Output is correct
27 Correct 146 ms 19196 KB Output is correct
28 Correct 153 ms 19068 KB Output is correct
29 Correct 157 ms 19104 KB Output is correct
30 Correct 181 ms 19108 KB Output is correct
31 Correct 266 ms 19124 KB Output is correct
32 Correct 90 ms 14488 KB Output is correct
33 Correct 268 ms 19728 KB Output is correct
34 Correct 135 ms 14524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 204 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 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 588 KB Output is correct
11 Correct 141 ms 19000 KB Output is correct
12 Correct 139 ms 18996 KB Output is correct
13 Correct 110 ms 17172 KB Output is correct
14 Correct 97 ms 17128 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 1 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 1 ms 204 KB Output is correct
23 Correct 73 ms 9672 KB Output is correct
24 Correct 50 ms 6064 KB Output is correct
25 Correct 39 ms 5068 KB Output is correct
26 Correct 32 ms 3552 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 252 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 1 ms 588 KB Output is correct
33 Correct 3 ms 564 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 1 ms 316 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 316 KB Output is correct
41 Correct 4 ms 716 KB Output is correct
42 Correct 5 ms 972 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 24 ms 3300 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 3 ms 588 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 78 ms 9664 KB Output is correct
52 Correct 34 ms 5216 KB Output is correct
53 Correct 30 ms 5312 KB Output is correct
54 Correct 38 ms 3020 KB Output is correct
55 Correct 95 ms 9140 KB Output is correct
56 Correct 17 ms 2020 KB Output is correct
57 Correct 146 ms 19196 KB Output is correct
58 Correct 153 ms 19068 KB Output is correct
59 Correct 157 ms 19104 KB Output is correct
60 Correct 181 ms 19108 KB Output is correct
61 Correct 266 ms 19124 KB Output is correct
62 Correct 90 ms 14488 KB Output is correct
63 Correct 268 ms 19728 KB Output is correct
64 Correct 135 ms 14524 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 48 ms 14516 KB Output is correct
67 Correct 129 ms 19792 KB Output is correct
68 Correct 141 ms 19136 KB Output is correct
69 Correct 30 ms 2020 KB Output is correct
70 Correct 7 ms 836 KB Output is correct
71 Correct 0 ms 332 KB Output is correct
72 Correct 38 ms 2880 KB Output is correct
73 Correct 8 ms 972 KB Output is correct
74 Correct 1 ms 324 KB Output is correct
75 Correct 156 ms 19036 KB Output is correct
76 Correct 159 ms 19048 KB Output is correct
77 Correct 176 ms 19096 KB Output is correct
78 Correct 211 ms 19148 KB Output is correct
79 Correct 261 ms 19128 KB Output is correct
80 Correct 277 ms 19064 KB Output is correct
81 Correct 236 ms 17052 KB Output is correct
82 Correct 239 ms 17132 KB Output is correct