Submission #703391

# Submission time Handle Problem Language Result Execution time Memory
703391 2023-02-27T08:32:17 Z Aestivate Self Study (JOI22_ho_t2) C++17
0 / 100
308 ms 5068 KB
#include<bits/stdc++.h>
#include<random>
using namespace std;

template<typename T> void _do(T x){cerr<<x<<"\n";}
template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);}
#define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__);

#define float double
#define ss(n) fixed<<setprecision(n) 
#define ll long long
#define int ll
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define rep(i,a) for(int i=1;i<=a;i++)
#define rep0(i,a) for(int i=0;i<a;i++)
#define F first
#define S second
#define uni(a) a.resize(distance(a.begin(),unique(a.begin(),a.end())));
#define unisort(a) sort(a.begin(),a.end()); uni(a);

ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);}

const ld pi=3.14159265358979323846264338327950288419716939931;
const int lar=3e18;
const int mol1=1e9+7;
const int mol2=998244353;
const int MX=3e5;


void solve()
{
    int n,m;
    cin>>n>>m;
    int a[n+1],b[n+1];
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];

        int l=0,r=8e18;
        int ans=0;
        while(l<r){
            int tt=0;
            int mid=l+r+1>>1;
            rep(i,n){
                if(a[i]>b[i]){
                    if(a[i]*m>=mid){
                        tt+=(mid/a[i])+(mid%a[i]?1:0);
                    }
                    else{
                        tt+=m;
                        int g1=mid-a[i]*m;
                        tt+=(g1/b[i])+(g1%b[i]?1:0);
                    }
                }
                else{
                    tt+=(mid/b[i])+(mid%b[i]?1:0);
                }
            }
            if(tt<=n*m) {
                ans=max(ans,mid);
                l=mid;
            }
            else{
                r=mid-1;
            }
        }
        cout<<ans<<"\n";
    
}

signed main()
{
    IO
    solve();
    return 0;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:45:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   45 |             int mid=l+r+1>>1;
      |                     ~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 188 ms 5068 KB Output is correct
12 Correct 176 ms 4996 KB Output is correct
13 Correct 168 ms 4948 KB Output is correct
14 Incorrect 308 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 87 ms 2648 KB Output is correct
10 Correct 64 ms 1876 KB Output is correct
11 Correct 42 ms 1468 KB Output is correct
12 Correct 34 ms 1252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 1 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 188 ms 5068 KB Output is correct
12 Correct 176 ms 4996 KB Output is correct
13 Correct 168 ms 4948 KB Output is correct
14 Incorrect 308 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 87 ms 2648 KB Output is correct
10 Correct 64 ms 1876 KB Output is correct
11 Correct 42 ms 1468 KB Output is correct
12 Correct 34 ms 1252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 1 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 188 ms 5068 KB Output is correct
12 Correct 176 ms 4996 KB Output is correct
13 Correct 168 ms 4948 KB Output is correct
14 Incorrect 308 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -