Submission #1094563

#TimeUsernameProblemLanguageResultExecution timeMemory
1094563IzzySelf Study (JOI22_ho_t2)C++14
0 / 100
0 ms348 KiB
#include <vector> #include <iostream> using namespace std; long long n, m; vector<int> course; vector<int> study; bool works(long long target) { vector<long long> vals(n); // value of each class rn long long hours = n * m; long long temp; long long left = 0; for (int i = 0; i < n; i++) { if (course[i] > study[i]) { temp = target / course[i]; if (target % course[i] != 0) { temp++; } temp = min(temp, m); hours -= temp; vals[i] += course[i] * temp; } if (vals[i] < target) { left = target - vals[i]; temp = left / study[i]; if (left % study[i] != 0) { temp++; } hours -= temp; vals[i] += temp * study[i]; } if (hours < 0) { return false; } cout << hours << ' '; } return true; } int main() { cin >> n >> m; course.resize(n); study.resize(n); for (int i = 0; i < n; i++) { cin >> course[i]; } for (int i = 0; i < n; i++) { cin >> study[i]; } // binary search for max min comprehension lvl long long low = 0; long long high = 1e18; long long mid; long long working = 0; while (low <= high) { mid = (low + high) / 2; if (works(mid)) { working = mid; low = mid + 1; } else { high = mid - 1; } } cout << working; }
#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...