Please sign in first.
Submission #74304654
Source Code Expand
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, k, a[200010], maxx = 0;
signed main () {
cin >> n >> k;
for (int i = 1; i <= n; i ++) {
cin >> a[i];
a[i] %= k;
}
sort(a + 1, a + n + 1);
for (int i = 2; i <= n; i ++) {
maxx = max(maxx, a[i] - a[i - 1]);
}
maxx = max(maxx, a[1] + k - a[n]);
cout << k - maxx;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Minimize Range |
| User | zhuchen |
| Language | C++23 (GCC 15.2.0) |
| Score | 400 |
| Code Size | 423 Byte |
| Status | AC |
| Exec Time | 65 ms |
| Memory | 5180 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 | 3420 KiB |
| 00_sample_02.txt | AC | 1 ms | 3508 KiB |
| 01_01.txt | AC | 32 ms | 4140 KiB |
| 01_02.txt | AC | 35 ms | 4472 KiB |
| 01_03.txt | AC | 53 ms | 4872 KiB |
| 01_04.txt | AC | 30 ms | 4224 KiB |
| 01_05.txt | AC | 20 ms | 3932 KiB |
| 01_06.txt | AC | 16 ms | 3804 KiB |
| 01_07.txt | AC | 8 ms | 3888 KiB |
| 01_08.txt | AC | 11 ms | 3724 KiB |
| 01_09.txt | AC | 43 ms | 4552 KiB |
| 01_10.txt | AC | 9 ms | 3804 KiB |
| 01_11.txt | AC | 19 ms | 4056 KiB |
| 01_12.txt | AC | 31 ms | 4332 KiB |
| 01_13.txt | AC | 12 ms | 3932 KiB |
| 01_14.txt | AC | 26 ms | 4040 KiB |
| 01_15.txt | AC | 17 ms | 3828 KiB |
| 01_16.txt | AC | 2 ms | 3636 KiB |
| 01_17.txt | AC | 46 ms | 4660 KiB |
| 01_18.txt | AC | 42 ms | 4572 KiB |
| 01_19.txt | AC | 58 ms | 4808 KiB |
| 01_20.txt | AC | 42 ms | 4492 KiB |
| 02_01.txt | AC | 1 ms | 3548 KiB |
| 02_02.txt | AC | 1 ms | 3428 KiB |
| 02_03.txt | AC | 1 ms | 3508 KiB |
| 02_04.txt | AC | 1 ms | 3632 KiB |
| 02_05.txt | AC | 1 ms | 3444 KiB |
| 02_06.txt | AC | 1 ms | 3280 KiB |
| 02_07.txt | AC | 20 ms | 5084 KiB |
| 02_08.txt | AC | 57 ms | 5056 KiB |
| 02_09.txt | AC | 52 ms | 4868 KiB |
| 02_10.txt | AC | 20 ms | 5168 KiB |
| 02_11.txt | AC | 57 ms | 4908 KiB |
| 02_12.txt | AC | 63 ms | 4992 KiB |
| 03_01.txt | AC | 64 ms | 4936 KiB |
| 03_02.txt | AC | 65 ms | 5044 KiB |
| 03_03.txt | AC | 64 ms | 4816 KiB |
| 03_04.txt | AC | 65 ms | 4840 KiB |
| 03_05.txt | AC | 64 ms | 4964 KiB |
| 03_06.txt | AC | 65 ms | 5180 KiB |
| 03_07.txt | AC | 64 ms | 4832 KiB |
| 03_08.txt | AC | 64 ms | 5108 KiB |
| 03_09.txt | AC | 65 ms | 5100 KiB |
| 03_10.txt | AC | 64 ms | 4956 KiB |