Submission #1003996

#TimeUsernameProblemLanguageResultExecution timeMemory
1003996CSQ31Self Study (JOI22_ho_t2)C++17
62 / 100
263 ms13904 KiB
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define sz(a) (int)(a.size()) #define all(a) a.begin(),a.end() #define lb lower_bound #define ub upper_bound #define owo ios_base::sync_with_stdio(0);cin.tie(0); #define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr) #define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\ debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC)) typedef long long int ll; typedef long double ld; typedef pair<ll,ll> PII; typedef pair<int,int> pii; typedef vector<vector<int>> vii; typedef vector<vector<ll>> VII; ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);} int main() { ll n,m; cin>>n>>m; vector<ll>a(n),b(n); for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++)cin>>b[i]; ll l = 0,r = 1e16; while(r>=l){ ll mid = (l+r)/2; bool ok = 1; ll f = 0; vector<ll>cnt(n,0); for(int i=0;i<n;i++){ if(a[i]<=b[i]){ f += m; continue; } cnt[i] = (mid+a[i]-1)/a[i]; cnt[i] = min(cnt[i],m); f += m-cnt[i]; } for(int i=0;i<n;i++){ ll tmp = mid - cnt[i]*a[i]; if(tmp<=0)continue; if((tmp+b[i]-1)/b[i] <= f){ f -= (tmp+b[i]-1)/b[i]; }else{ ok = 0; break; } } if(ok)l = mid+1; else r = mid-1; } cout<<r<<'\n'; }
#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...