Submission #74276613
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main(void){
int n, k;
cin >> n >> k;
vector<long long> a(2 * n, 10000000000000);
for(int i = 0; i < n; i++){
cin >> a[i];
a[i] %= k;
}
long long min = 1000000000000;
sort(a.begin(), a.end());
for(int i = 0; i < n; i++){
long long t = a[n+i-1] - a[i];
if(t < min){
min = t;
}
a[n+i] = a[i] + k;
}
cout << min << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Minimize Range |
| User | mrkm1627 |
| Language | C++23 (GCC 15.2.0) |
| Score | 400 |
| Code Size | 508 Byte |
| Status | AC |
| Exec Time | 61 ms |
| Memory | 6616 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 | 3520 KiB |
| 00_sample_02.txt | AC | 1 ms | 3572 KiB |
| 01_01.txt | AC | 31 ms | 4932 KiB |
| 01_02.txt | AC | 34 ms | 4956 KiB |
| 01_03.txt | AC | 51 ms | 5924 KiB |
| 01_04.txt | AC | 28 ms | 4820 KiB |
| 01_05.txt | AC | 19 ms | 4308 KiB |
| 01_06.txt | AC | 15 ms | 4060 KiB |
| 01_07.txt | AC | 7 ms | 3680 KiB |
| 01_08.txt | AC | 10 ms | 3720 KiB |
| 01_09.txt | AC | 41 ms | 5380 KiB |
| 01_10.txt | AC | 8 ms | 3588 KiB |
| 01_11.txt | AC | 18 ms | 4216 KiB |
| 01_12.txt | AC | 29 ms | 4828 KiB |
| 01_13.txt | AC | 12 ms | 3960 KiB |
| 01_14.txt | AC | 24 ms | 4600 KiB |
| 01_15.txt | AC | 16 ms | 4148 KiB |
| 01_16.txt | AC | 2 ms | 3620 KiB |
| 01_17.txt | AC | 43 ms | 5640 KiB |
| 01_18.txt | AC | 40 ms | 5340 KiB |
| 01_19.txt | AC | 56 ms | 6116 KiB |
| 01_20.txt | AC | 40 ms | 5220 KiB |
| 02_01.txt | AC | 1 ms | 3460 KiB |
| 02_02.txt | AC | 1 ms | 3480 KiB |
| 02_03.txt | AC | 1 ms | 3480 KiB |
| 02_04.txt | AC | 1 ms | 3616 KiB |
| 02_05.txt | AC | 1 ms | 3492 KiB |
| 02_06.txt | AC | 1 ms | 3576 KiB |
| 02_07.txt | AC | 20 ms | 6344 KiB |
| 02_08.txt | AC | 55 ms | 6364 KiB |
| 02_09.txt | AC | 50 ms | 6460 KiB |
| 02_10.txt | AC | 20 ms | 6408 KiB |
| 02_11.txt | AC | 54 ms | 6436 KiB |
| 02_12.txt | AC | 61 ms | 6408 KiB |
| 03_01.txt | AC | 61 ms | 6372 KiB |
| 03_02.txt | AC | 61 ms | 6372 KiB |
| 03_03.txt | AC | 61 ms | 6616 KiB |
| 03_04.txt | AC | 61 ms | 6460 KiB |
| 03_05.txt | AC | 61 ms | 6364 KiB |
| 03_06.txt | AC | 61 ms | 6492 KiB |
| 03_07.txt | AC | 61 ms | 6412 KiB |
| 03_08.txt | AC | 61 ms | 6484 KiB |
| 03_09.txt | AC | 61 ms | 6412 KiB |
| 03_10.txt | AC | 61 ms | 6412 KiB |