# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
536942 |
2022-03-14T07:57:50 Z |
groshi |
Martian DNA (BOI18_dna) |
C++17 |
|
502 ms |
20520 KB |
#include<iostream>
#include<vector>
#include<map>
using namespace std;
map<int,int> zle;
map<int,int> mapka;
map<int,int> mam;
map<int,int>::iterator it,it2;
int t[1000000];
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int n,k,r,x,y;
cin>>n>>k>>r;
for(int i=1;i<=n;i++)
cin>>t[i];
for(int i=1;i<=r;i++)
{
cin>>x>>y;
mapka[x]=y;
mam[x]=0;
zle[x]=1;
}
int pocz=1;
int wynik=1000000000;
for(int i=1;i<=n;i++)
{
mam[t[i]]++;
it=zle.find(t[i]);
if(it!=zle.end())
{
it2=mapka.find(t[i]);
if(mam[t[i]]>=it2->second)
zle.erase(it);
}
it2=mapka.find(t[pocz]);
while(pocz<=i && mam[t[pocz]]>it2->second)
{
mam[t[pocz]]--;
pocz++;
it2=mapka.find(t[pocz]);
}
if(zle.size()==0)
wynik=min(wynik,i-pocz+1);
}
if(wynik==1000000000)
cout<<"impossible";
else cout<<wynik;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
288 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
468 KB |
Output is correct |
4 |
Correct |
3 ms |
472 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1424 KB |
Output is correct |
2 |
Correct |
16 ms |
1456 KB |
Output is correct |
3 |
Correct |
22 ms |
1532 KB |
Output is correct |
4 |
Correct |
21 ms |
1532 KB |
Output is correct |
5 |
Correct |
120 ms |
6004 KB |
Output is correct |
6 |
Correct |
22 ms |
1492 KB |
Output is correct |
7 |
Correct |
24 ms |
1620 KB |
Output is correct |
8 |
Correct |
235 ms |
11768 KB |
Output is correct |
9 |
Correct |
69 ms |
2424 KB |
Output is correct |
10 |
Correct |
24 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
484 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
405 ms |
14128 KB |
Output is correct |
2 |
Correct |
250 ms |
11144 KB |
Output is correct |
3 |
Correct |
188 ms |
6256 KB |
Output is correct |
4 |
Correct |
14 ms |
1492 KB |
Output is correct |
5 |
Correct |
342 ms |
15428 KB |
Output is correct |
6 |
Correct |
502 ms |
20520 KB |
Output is correct |
7 |
Correct |
82 ms |
3280 KB |
Output is correct |
8 |
Correct |
157 ms |
4468 KB |
Output is correct |
9 |
Correct |
30 ms |
1504 KB |
Output is correct |
10 |
Correct |
15 ms |
1408 KB |
Output is correct |
11 |
Correct |
20 ms |
1496 KB |
Output is correct |
12 |
Correct |
20 ms |
1468 KB |
Output is correct |
13 |
Correct |
126 ms |
6004 KB |
Output is correct |
14 |
Correct |
33 ms |
1388 KB |
Output is correct |
15 |
Correct |
35 ms |
1612 KB |
Output is correct |
16 |
Correct |
218 ms |
11632 KB |
Output is correct |
17 |
Correct |
68 ms |
2400 KB |
Output is correct |
18 |
Correct |
31 ms |
1468 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
3 ms |
468 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |