-
Notifications
You must be signed in to change notification settings - Fork 32
/
MinimumDistances.c
57 lines (55 loc) · 974 Bytes
/
MinimumDistances.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int n, i, j, k, t, s = 0, o = 0, e = 0;
scanf("%d", &t);
int a[t], b[t];
for (i = 0; i < t; i++)
{
scanf("%d", &a[i]);
}
for (i = 0; i < t; i++)
{
s = 0;
o = 0;
e = 0;
for (j = i + 1; j < t; j++)
{
s++;
if (a[i] == a[j])
{
e = 1;
break;
}
else
{
o++;
}
}
if (e == 1)
b[i] = s;
else
b[i] = 0;
}
k = 10000;
for (i = 0; i < t; i++)
{
if (b[i] < k && b[i] > 0)
{
k = b[i];
}
}
if (k == 10000)
printf("-1");
else
printf("%d", k);
return 0;
}