Submission #74316664
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
long long x;
cin >> x;
a[i] = x % k;
}
sort(a.begin(), a.end());
vector<int>r = a;
for (auto x : a) {
r.push_back(x + k);
}
int minn = INT_MAX;
for (int i = 0; i < n; i++) {
int sum = r[i + n - 1] - r[i];
minn = min(minn, sum);
}
cout << minn;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Minimize Range |
| User | Eason0709 |
| Language | C++23 (GCC 15.2.0) |
| Score | 400 |
| Code Size | 437 Byte |
| Status | AC |
| Exec Time | 68 ms |
| Memory | 5748 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 01_01.txt, 01_02.txt, 01_03.txt, 01_04.txt, 01_05.txt, 01_06.txt, 01_07.txt, 01_08.txt, 01_09.txt, 01_10.txt, 01_11.txt, 01_12.txt, 01_13.txt, 01_14.txt, 01_15.txt, 01_16.txt, 01_17.txt, 01_18.txt, 01_19.txt, 01_20.txt, 02_01.txt, 02_02.txt, 02_03.txt, 02_04.txt, 02_05.txt, 02_06.txt, 02_07.txt, 02_08.txt, 02_09.txt, 02_10.txt, 02_11.txt, 02_12.txt, 03_01.txt, 03_02.txt, 03_03.txt, 03_04.txt, 03_05.txt, 03_06.txt, 03_07.txt, 03_08.txt, 03_09.txt, 03_10.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 1 ms | 3376 KiB |
| 00_sample_02.txt | AC | 1 ms | 3496 KiB |
| 01_01.txt | AC | 34 ms | 4596 KiB |
| 01_02.txt | AC | 37 ms | 4660 KiB |
| 01_03.txt | AC | 56 ms | 5356 KiB |
| 01_04.txt | AC | 31 ms | 4440 KiB |
| 01_05.txt | AC | 21 ms | 4084 KiB |
| 01_06.txt | AC | 16 ms | 3800 KiB |
| 01_07.txt | AC | 8 ms | 3812 KiB |
| 01_08.txt | AC | 11 ms | 3800 KiB |
| 01_09.txt | AC | 46 ms | 4912 KiB |
| 01_10.txt | AC | 9 ms | 3976 KiB |
| 01_11.txt | AC | 20 ms | 4004 KiB |
| 01_12.txt | AC | 32 ms | 4456 KiB |
| 01_13.txt | AC | 13 ms | 3780 KiB |
| 01_14.txt | AC | 26 ms | 4328 KiB |
| 01_15.txt | AC | 17 ms | 3952 KiB |
| 01_16.txt | AC | 2 ms | 3624 KiB |
| 01_17.txt | AC | 46 ms | 5024 KiB |
| 01_18.txt | AC | 43 ms | 4916 KiB |
| 01_19.txt | AC | 62 ms | 5488 KiB |
| 01_20.txt | AC | 45 ms | 4908 KiB |
| 02_01.txt | AC | 1 ms | 3456 KiB |
| 02_02.txt | AC | 1 ms | 3400 KiB |
| 02_03.txt | AC | 1 ms | 3640 KiB |
| 02_04.txt | AC | 1 ms | 3592 KiB |
| 02_05.txt | AC | 1 ms | 3428 KiB |
| 02_06.txt | AC | 1 ms | 3592 KiB |
| 02_07.txt | AC | 22 ms | 5708 KiB |
| 02_08.txt | AC | 60 ms | 5720 KiB |
| 02_09.txt | AC | 55 ms | 5720 KiB |
| 02_10.txt | AC | 21 ms | 5736 KiB |
| 02_11.txt | AC | 59 ms | 5720 KiB |
| 02_12.txt | AC | 66 ms | 5744 KiB |
| 03_01.txt | AC | 68 ms | 5748 KiB |
| 03_02.txt | AC | 66 ms | 5744 KiB |
| 03_03.txt | AC | 68 ms | 5720 KiB |
| 03_04.txt | AC | 66 ms | 5708 KiB |
| 03_05.txt | AC | 68 ms | 5716 KiB |
| 03_06.txt | AC | 68 ms | 5720 KiB |
| 03_07.txt | AC | 67 ms | 5720 KiB |
| 03_08.txt | AC | 68 ms | 5700 KiB |
| 03_09.txt | AC | 68 ms | 5736 KiB |
| 03_10.txt | AC | 68 ms | 5736 KiB |