# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
703049 | Ronin13 | Martian DNA (BOI18_dna) | C++14 | 73 ms | 14104 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int nmax = 2000001;
ll dp[nmax][32];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n, k, r; cin >> n >> k >> r;
vector <vector <int> > vec(k + 1);
int a[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i];
vec[a[i]].pb(i);
}
vector <int> ind(k + 1, -1);
int mx = 0;
for(int i = 1; i <= r; i++){
int b, q; cin >> b >> q;
ind[b] = q - 1;
if(vec[b].size() <= ind[b]){
cout << "impossible\n";
return 0;
}
mx = max(mx, vec[b][q - 1]);
}
int ans = 1e9;
for(int i = 1; i <= n; i++){
ans = min(ans, mx - i + 1);
if(ind[a[i]] != -1){
ind[a[i]]++;
if(ind[a[i]] == vec[a[i]].size()) break;
mx = max(mx, vec[a[i]][ind[a[i]]]);
}
}
cout << ans;
return 0;
}
Compilation message (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... |