Submission #74288844
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,char> pic;
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(x) ((int)x.size())
ll ksm(ll a,ll b,ll p){if (p == 1)return 0;if (b == 0)return 1%p;
ll ans = 1; a %= p;while (b > 0){if (b&1){ans = ans*a%p;}a = (a*a)
%p;b >>= 1;}return ans;}
const int mod = 1e9+7;
const int P = 998244353;
const ll inf = (1LL << 50LL);
const ll N = 5010;
int n,k,mi = 1 << 30;
int a[200010];
int b[200010],rear = 0;
map<int,int> f;
int main(){
scanf("%d%d",&n,&k);
for (int i = 1;i <= n;i++){
scanf("%d",&a[i]);
b[i] = a[i]%k;
}
sort(b+1,b+n+1);
mi = min(mi,b[n]-b[1]);
for (int i = 1;i <= n;i++){
mi = min(mi,b[i]+k-b[i+1]);
}
printf("%d",mi);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Minimize Range |
| User | wuqize |
| Language | C++23 (GCC 15.2.0) |
| Score | 400 |
| Code Size | 858 Byte |
| Status | AC |
| Exec Time | 26 ms |
| Memory | 5408 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 | 3640 KiB |
| 00_sample_02.txt | AC | 1 ms | 3732 KiB |
| 01_01.txt | AC | 13 ms | 4512 KiB |
| 01_02.txt | AC | 15 ms | 4636 KiB |
| 01_03.txt | AC | 22 ms | 5048 KiB |
| 01_04.txt | AC | 12 ms | 4640 KiB |
| 01_05.txt | AC | 9 ms | 4384 KiB |
| 01_06.txt | AC | 7 ms | 4196 KiB |
| 01_07.txt | AC | 3 ms | 4128 KiB |
| 01_08.txt | AC | 5 ms | 4068 KiB |
| 01_09.txt | AC | 18 ms | 5024 KiB |
| 01_10.txt | AC | 4 ms | 4068 KiB |
| 01_11.txt | AC | 8 ms | 4312 KiB |
| 01_12.txt | AC | 13 ms | 4564 KiB |
| 01_13.txt | AC | 5 ms | 4132 KiB |
| 01_14.txt | AC | 11 ms | 4372 KiB |
| 01_15.txt | AC | 7 ms | 4116 KiB |
| 01_16.txt | AC | 1 ms | 3888 KiB |
| 01_17.txt | AC | 19 ms | 4896 KiB |
| 01_18.txt | AC | 17 ms | 4836 KiB |
| 01_19.txt | AC | 24 ms | 5336 KiB |
| 01_20.txt | AC | 17 ms | 4784 KiB |
| 02_01.txt | AC | 1 ms | 3716 KiB |
| 02_02.txt | AC | 1 ms | 3800 KiB |
| 02_03.txt | AC | 1 ms | 3748 KiB |
| 02_04.txt | AC | 1 ms | 3648 KiB |
| 02_05.txt | AC | 1 ms | 3744 KiB |
| 02_06.txt | AC | 1 ms | 3744 KiB |
| 02_07.txt | AC | 11 ms | 5344 KiB |
| 02_08.txt | AC | 15 ms | 5348 KiB |
| 02_09.txt | AC | 15 ms | 5280 KiB |
| 02_10.txt | AC | 11 ms | 5276 KiB |
| 02_11.txt | AC | 15 ms | 5284 KiB |
| 02_12.txt | AC | 26 ms | 5280 KiB |
| 03_01.txt | AC | 25 ms | 5176 KiB |
| 03_02.txt | AC | 26 ms | 5396 KiB |
| 03_03.txt | AC | 25 ms | 5276 KiB |
| 03_04.txt | AC | 26 ms | 5280 KiB |
| 03_05.txt | AC | 26 ms | 5408 KiB |
| 03_06.txt | AC | 25 ms | 5348 KiB |
| 03_07.txt | AC | 26 ms | 5396 KiB |
| 03_08.txt | AC | 26 ms | 5176 KiB |
| 03_09.txt | AC | 26 ms | 5348 KiB |
| 03_10.txt | AC | 25 ms | 5336 KiB |