Submission #952752

#TimeUsernameProblemLanguageResultExecution timeMemory
952752stakamanSwimming competition (LMIO18_plaukimo_varzybos)C++14
10 / 100
341 ms11080 KiB
#include <bits/stdc++.h> using namespace std; bool canDivide(vector<int>& times, int maxDiff, int A, int B, int N) { int groups = 0, i = 0; while (i < N) { int start_time = times[i]; int members = 0; while (i < N && members < B && times[i] - start_time <= maxDiff) { i++; members++; } if (members < A) return false; // Cannot form a valid group groups++; } return true; } int main() { int N, A, B; cin >> N >> A >> B; vector<int> times(N); for (int& time : times) cin >> time; sort(times.begin(), times.end()); int low = 0, high = times.back() - times.front(), ans = high; while (low <= high) { int mid = low + (high - low) / 2; if (canDivide(times, mid, A, B, N)) { ans = mid; high = mid - 1; } else { low = mid + 1; } } cout << ans << 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...