# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1003051 | daffuwu | Martian DNA (BOI18_dna) | C++14 | 26 ms | 3932 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, k, r, b, q, cnt[200069], d[200069], cvio, ans = 1e9;
void chg(int x, int y)
{
int prev = cnt[x];
cnt[x] += y;
if (prev == -1 && cnt[x] == 0) cvio--;
else if (prev == 0 && cnt[x] == -1) cvio++;
}
int main()
{
int i, j;
scanf("%d%d%d", &n, &k, &r);
for (i=1; i<=n; i++) scanf("%d", d+i);
for (i=1; i<=r; i++)
{
scanf("%d%d", &b, &q);
cnt[b] = -q;
cvio++;
}
for (i=1, j=1; i<=n; i++)
{
chg(d[i], 1);
for (; j<i && cvio == 0; chg(d[j++], -1));
for (;j>1 && cvio>0; chg(d[--j], 1));
if (cvio == 0) ans = min(ans, i-j+1);
}
if (ans == 1e9) printf("impossible\n");
else printf("%d\n", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |