Submission #1094562

#TimeUsernameProblemLanguageResultExecution timeMemory
1094562stefdascaSelf Study (JOI22_ho_t2)C++14
100 / 100
129 ms8024 KiB
// https://stefdasca.ro -> for tutoring #include <iostream> #include <vector> using namespace std; int solve(long long target, int n, int m, vector<int> &classes, vector<int> &study) { long long hours = 1LL * n * m; // how many hours of study i have left // find out classes for which it's better to go to the courses for (int i = 0; i < n; i++) { long long required = target; if (classes[i] > study[i]) { long long needed = required / classes[i]; if (required % classes[i] > 0) { needed++; } if (needed > m) { needed = m; } required = max(0LL, required - needed * classes[i]); hours -= needed; } // subtract comprehension value based on remaining time long long needed = required / study[i]; if (required % study[i] > 0) { needed++; } hours -= needed; if (hours < 0) { return 0; } } return 1; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector <int> classes(n), study(n); for (int i = 0; i < n; i++) { cin >> classes[i]; } for (int i = 0; i < n; i++) { cin >> study[i]; } long long L = 0; long long R = 1e18; long long ans = 0; while (L <= R) { long long mid = (L + R) / 2; if (solve(mid, n, m, classes, study)) { ans = mid; L = mid + 1; } else { R = mid - 1; } } cout << ans << '\n'; 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...