Submission #920336

#TimeUsernameProblemLanguageResultExecution timeMemory
920336KiaRezSelf Study (JOI22_ho_t2)C++17
62 / 100
346 ms11592 KiB
/* IN THE NAME OF GOD */ #include <bits/stdc++.h> // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef long double ld; #define F first #define S second #define Mp make_pair #define pb push_back #define pf push_front #define size(x) ((ll)x.size()) #define all(x) (x).begin(),(x).end() #define kill(x) cout << x << '\n', exit(0); #define fuck(x) cout << "(" << #x << " , " << x << ")" << endl #define endl '\n' const int N = 3e5+23, lg = 18; ll Mod = 1e9+7; //998244353; inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;} inline ll poww(ll a, ll b, ll mod=Mod) { ll ans = 1; a=MOD(a, mod); while (b) { if (b & 1) ans = MOD(ans*a, mod); b >>= 1; a = MOD(a*a, mod); } return ans; } ll n, m, a[N], b[N]; int main () { ios_base::sync_with_stdio(false), cin.tie(0); cin>>n>>m; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i++) cin>>b[i]; ll l=0, r=1e18; while(r-l > 1) { __int128 mid = (l+r)/2; __int128 num = 0, yey = 1; for(int i=1; i<=n; i++) { if(a[i] >= b[i]) { ll x = (mid+a[i]-1)/a[i]; x = min(x, m); num -= (m-x); ll f = mid - x*a[i]; num += max(0ll, (f-1+b[i])/b[i]); } else { ll x = (mid+a[i]-1)/b[i]; x = min(x, m); num -= (m-x); ll f = mid - x*b[i]; num += max(0ll, (f-1+b[i])/b[i]); } } if(num <= 0) l=mid; else r=mid; } cout<<l<<endl; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:53:21: warning: unused variable 'yey' [-Wunused-variable]
   53 |   __int128 num = 0, yey = 1;
      |                     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...