# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
709480 | stevancv | Martian DNA (BOI18_dna) | C++14 | 188 ms | 143160 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 2e5 + 5;
const int inf = 1e9;
const int mod = 1e9 + 7;
deque<int> dq[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m, k;
cin >> n >> m >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> b(m);
for (int i = 0; i < k; i++) {
int x, y;
cin >> x >> y;
b[x] = y;
}
set<int> s;
int dobri = 0;
int ans = 1e6;
for (int i = 0; i < n; i++) {
if (b[a[i]] == 0) continue;
dq[a[i]].push_back(i);
if (dq[a[i]].size() > b[a[i]]) {
s.erase(dq[a[i]].front());
dq[a[i]].pop_front();
s.insert(dq[a[i]].front());
}
else if (dq[a[i]].size() == b[a[i]]) {
s.insert(dq[a[i]].front());
dobri += 1;
}
if (dobri == k) smin(ans, i - *s.begin() + 1);
}
if (ans == 1e6) cout << "impossible" << en;
else cout << ans << en;
return 0;
}
컴파일 시 표준 에러 (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... |