QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201421 | #1955. Double Rainbow | std_abs# | WA | 0ms | 3756kb | C++17 | 806b | 2023-10-05 14:14:40 | 2023-10-05 14:14:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
const int N = 10005;
int n,k,a[N],cnt[N],cnt2[N];
int main() {
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> k;
for(int i=0; i<n; ++i) cin >> a[i],a[i]--,cnt[a[i]]++;
int res=1e9;
for(int i=0; i<n; ++i){
int x=0;
memset(cnt2,0,sizeof cnt2);
for(int j=i; j<n; ++j){
if(!cnt2[a[j]]) x++;
if(x==k){
res=min(res,j-i+1);
break;
}
cnt2[a[j]]++;
if(cnt2[a[j]]==cnt[a[j]]) break;
}
}
if(res>1e8) cout << "0\n";
else cout << res << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3756kb
input:
1 1 1
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'