Competitive Programming Library
Translate
Views
Friday, July 8, 2022
Solution Kattis - Awkward Party
Link Problem
:
https://open.kattis.com/problems/awkwardparty
Submission 9119079
Edit and resubmit
ID
DATE
PROBLEM
STATUS
CPU
LANG
TEST CASES
9119079
14:01:25
Awkward Party
Accepted
0.05 s
C++
6/6
Files submitted
awkwardparty.cpp
Download file
#include
<bits/stdc++.h>
using
namespace
std
;
map
<
int
,
int
>
pos
;
int
main
(
)
{
int
n
;
cin
>>
n
;
int
res
=
n
;
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
int
x
;
cin
>>
x
;
if
(
pos
.
count
(
x
))
res
=
min
(
res
,
i
-
pos
[
x
])
;
else
pos
[
x
]
=
i
;
}
cout
<<
res
;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment