Submission #1057457

#TimeUsernameProblemLanguageResultExecution timeMemory
1057457sammyuriRoom Temperature (JOI24_ho_t1)C++17
100 / 100
136 ms7112 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; vector<int> nums(n); for (auto &a : nums) { cin >> a; a %= t; } sort(nums.begin(), nums.end()); if (nums[0] == nums[n - 1]) { cout << 0 << endl; return 0; } // find largest gap in the numbers, then it is optimal to choose the // opposite point of that gap int best = t; for (int i = 0; i < n; i ++) { int gap = (nums[(i + 1) % n] - nums[i] + t) % t; int kk = t - gap; // cout << kk << endl; best = min(best, (kk + 1) / 2); } 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...