# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1013714 | kebine | Martian DNA (BOI18_dna) | C++17 | 22 ms | 6748 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int long long
// Whatever happens... God had made a plan for you.♡
int con[2000001];
int countd[200001];
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k, r;
int ans = INT_MAX;
int arr[200001];
cin >> n >> k >> r;
for (int i = 1; i <= n; i++)
{
cin >> arr[i];
}
int ind, cnt;
for (int i = 0; i < r; i++)
{
cin >> ind >> cnt;
con[ind] = 1;
countd[ind] += cnt;
}
int miau = r;
bool temp = 1;
int start = 1, stop = 1;
while (stop <= n)
{
if (miau != 0)
{
if (con[arr[stop]])
{
if (countd[arr[stop]] == 1)
{
miau--;
}
countd[arr[stop]]--;
}
stop++;
}
else
{
ans = min(ans, stop - 1 - start + 1);
// cout << stop << " " << start << endl;
if (con[arr[start]])
{
countd[arr[start]]++;
}
if (countd[arr[start]] > 0)
miau++;
start++;
}
}
if (ans == INT_MAX)
cout << "impossible" << endl;
else
cout << ans << endl;
}
컴파일 시 표준 에러 (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... |