Submission #548691

#TimeUsernameProblemLanguageResultExecution timeMemory
548691cpp219Self Study (JOI22_ho_t2)C++17
100 / 100
280 ms9120 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second #define debug(y) cout<<y,exit(0) using namespace std; typedef pair<ll,ll> LL; const ll N = 3e5 + 9; const ll inf = 1e18 + 7; int n,m,a[N],b[N]; bool chk(ll tar){ ll spare = 0; for (ll i = 1;i <= n;i++){ ll mx = max(a[i],b[i]); if (m*mx > tar) spare += m - ceil((ld)tar/mx); else spare -= ceil((ld)(tar - mx*m)/b[i]); } return (spare >= 0); } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".inp","r")){ freopen(task".inp","r",stdin); //freopen(task".out","w",stdout); } cin>>n>>m; for (ll i = 1;i <= n;i++) cin>>a[i]; for (ll i = 1;i <= n;i++) cin>>b[i]; ll l,mid,h; l = 1; h = inf; //debug(chk(18)); while(l <= h){ mid = (l + h)/2; if (chk(mid)) l = mid + 1; else h = mid - 1; } cout<<h; } /// be confident

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...