Submission #914972

# Submission time Handle Problem Language Result Execution time Memory
914972 2024-01-23T03:48:04 Z ReLice Self Study (JOI22_ho_t2) C++14
10 / 100
109 ms 5140 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool f=0;
    if (x>y){x=y;f=1;}
    return f;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool f=0;
    if (x<y){x=y;f=1;}
    return f;
}
//void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=2e18+7;
const ll mod=1e9+7;
const ll N=1e5+7;
const ld eps=1e-9;
istream& operator>>( istream& src, __int128_t& value) {
	long long v;src>>v;
	value = (ll)v;
	return src;
}
void solve(){
    ll i,j;
    ll n,m;
    cin>>n>>m;
    vll a(n),b(n);
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++){
        cin>>b[i];
        if(b[i]>a[i])a[i]=b[i];
    }
    if(m==1){
        ll ans=inf;
        for(i=0;i<n;i++) ans=min(ans,a[i]);
        cout<<ans<<endl;
        return;
    }
    ll lo = 0;
    ll hi = 2e18;
    while(lo+1<hi){
        ll mid = lo+(hi-lo)/2;
        ll cost = 0;
        for(i=0;i<n;i++) {
            ll inclass = (mid+a[i]-1)/a[i];
            if(inclass>m){
                inclass=m;
                ll outclass = (mid-inclass*a[i]+b[i]-1)/b[i];
                cost+=outclass;
            }
            cost+=inclass;
        }
        if(cost<=n*m) lo=mid;
        else hi=mid;
    }
    cout<<lo<<endl;
}

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
    ll t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
/*



*/

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:51:10: warning: unused variable 'j' [-Wunused-variable]
   51 |     ll i,j;
      |          ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 47 ms 4956 KB Output is correct
12 Correct 50 ms 4956 KB Output is correct
13 Correct 36 ms 5140 KB Output is correct
14 Correct 35 ms 4952 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 26 ms 4956 KB Output is correct
17 Correct 48 ms 5136 KB Output is correct
18 Correct 45 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 26 ms 4956 KB Output is correct
3 Correct 48 ms 5136 KB Output is correct
4 Correct 45 ms 4952 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 109 ms 2792 KB Output is correct
14 Correct 71 ms 1884 KB Output is correct
15 Correct 53 ms 1624 KB Output is correct
16 Correct 43 ms 1372 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Incorrect 8 ms 528 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 47 ms 4956 KB Output is correct
12 Correct 50 ms 4956 KB Output is correct
13 Correct 36 ms 5140 KB Output is correct
14 Correct 35 ms 4952 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 109 ms 2792 KB Output is correct
24 Correct 71 ms 1884 KB Output is correct
25 Correct 53 ms 1624 KB Output is correct
26 Correct 43 ms 1372 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 8 ms 528 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 109 ms 2792 KB Output is correct
10 Correct 71 ms 1884 KB Output is correct
11 Correct 53 ms 1624 KB Output is correct
12 Correct 43 ms 1372 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 8 ms 528 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 47 ms 4956 KB Output is correct
12 Correct 50 ms 4956 KB Output is correct
13 Correct 36 ms 5140 KB Output is correct
14 Correct 35 ms 4952 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 109 ms 2792 KB Output is correct
24 Correct 71 ms 1884 KB Output is correct
25 Correct 53 ms 1624 KB Output is correct
26 Correct 43 ms 1372 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 8 ms 528 KB Output isn't correct
33 Halted 0 ms 0 KB -