Submission #1117522

#TimeUsernameProblemLanguageResultExecution timeMemory
1117522wellthen_Self Study (JOI22_ho_t2)C++17
0 / 100
374 ms9992 KiB
#include <bits/stdc++.h> #include <climits> using namespace std; typedef long long ll; bool works(ll mid, vector<ll> classes, vector<ll> selfstudy, ll n, ll m){ ll time = n*m; for(ll i = 0; i<ll(classes.size()); i++){ ll need = mid; if(classes[i] > selfstudy[i]){ //classes are more productive ll classhours = mid/classes[i]; if(mid%classes[i] != 0){ classhours++; } classhours = min(classhours, m); need = max(0ll, need-(classhours*classes[i])); time-=classhours; if(need>0){ ll selfstudyhours = need/selfstudy[i]; if(need%selfstudy[i] != 0){ selfstudyhours++; } time-=selfstudyhours; } } else{ //selfstudy is more productive int selfstudyhours = mid/selfstudy[i]; if(mid%selfstudy[i] != 0){ selfstudyhours++; } time-=selfstudyhours; } if(time < 0) return false; } return time>=0; } int main() { ll n, m; cin >> n >> m; vector<ll> classes(n), selfstudy(n); for (int i = 0; i < n; i++) { cin >> classes[i]; } for (int i = 0; i < n; i++) { cin >> selfstudy[i]; } ll lo = 0, hi = ll(1e18), best = 0; while (lo <= hi) { ll mid = (lo+hi)/2; if (works(mid, classes, selfstudy, n, m)) { best = mid; lo = mid + 1; } else { hi = mid - 1; } } cout << best << endl; return 0; }
#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...