Submit solution
Points:
0.01 (partial)
Time limit:
1.0s
Memory limit:
512M
Problem types
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch
In case the statement didn't load correctly, you can download the statement here: Statement
Lưu ý: các bạn không nhập, xuất dữ liệu bằng file kể cả khi đề bài có yêu cầu. Đọc, ghi dữ liệu được thực hiện ở stdin và stdout.
Comments
<#include <bits/stdc++.h>
define ll long long
define IOS iosbse::syncwith_stdio(false); cin.tie(NULL); cout.tie(NULL);
define vti vector <int>
define vtll vector <long long>
define vtf vector <float>
define str string
define el cout << "\n"
using namespace std; int main() { IOS; int n; cin >> n; vti a(n); int minDiff = 10e5, isFind = 0; for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = 0; j < i; j++) { if (a[i] == a[j] && minDiff > abs(i - j)) { minDiff = abs(i - j); isFind = 1; } } } if (isFind) cout << minDiff << endl; else cout << -1 << endl;
}/>
This comment is hidden due to too much negative feedback. Show it anyway.
Bài MINDIST làm thế này 👇
This comment is hidden due to too much negative feedback. Show it anyway.