# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
547973 | Jarif_Rahman | Martian DNA (BOI18_dna) | C++17 | 147 ms | 137676 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k, r; cin >> n >> k >> r;
vector<int> v(n);
for(int &x: v) cin >> x;
vector<queue<int>> sth(k);
vector<int> req(k, 0);
for(int i = 0; i < r; i++){
int b, q; cin >> b >> q;
req[b] = q;
}
int tbo = r;
set<int> ss;
int ans = 1e9;
for(int i = 0; i < n; i++){
if(sth[v[i]].size() < req[v[i]]){
sth[v[i]].push(i);
ss.insert(i);
if(sth[v[i]].size() == req[v[i]]) tbo--;
}
else if(req[v[i]] != 0){
sth[v[i]].push(i);
ss.insert(i);
ss.erase(sth[v[i]].front());
sth[v[i]].pop();
}
if(tbo == 0) ans = min(ans, i-*ss.begin()+1);
}
if(ans > n) cout << "impossible\n";
else cout << ans << "\n";
}
컴파일 시 표준 에러 (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... |