Submission #329909

# Submission time Handle Problem Language Result Execution time Memory
329909 2020-11-23T05:30:54 Z nandonathaniel Martian DNA (BOI18_dna) C++14
0 / 100
24 ms 3308 KB
#include<bits/stdc++.h>
using namespace std;

int mini[10],skg[10];
int s[200005];
vector<int> v;

bool check(){
	for(auto i : v){
		if(skg[i]<mini[i])return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,k,r,x,y;
    cin >> n >> k >> r;
    for(int i=0;i<n;i++)cin >> s[i];
    for(int i=1;i<=r;i++){
    	cin >> x >> y;
    	v.push_back(x);
    	mini[x]=y;
	}
	int ans=n+1;
    int awal=0,akhir=0;
    skg[s[0]]++;
    while(awal<=akhir && akhir<n){
    	bool stat=check();
    	if(!stat){
    		if(akhir<n-1){
    			akhir++;
    			skg[s[akhir]]++;
			}
			else break;
		}
		else{
			ans=min(ans,akhir-awal+1);
			skg[s[awal]]--;
			awal++;
		}
	}
	if(ans==n+1)cout << "impossible\n";
	else cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1132 KB Output is correct
2 Correct 15 ms 1132 KB Output is correct
3 Correct 19 ms 1132 KB Output is correct
4 Correct 17 ms 1132 KB Output is correct
5 Runtime error 23 ms 2540 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 3308 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -