# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
931338 |
2024-02-21T15:43:44 Z |
daulet |
Martian DNA (BOI18_dna) |
C++14 |
|
355 ms |
27052 KB |
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie()
#define ll long long
#define ull unsigned long long
#define pb push_back
#define endl "\n"
#define int ll
#define F first
#define S second
// ||
// ||
// ||
#define db double
// #define ld long double
#define short unsigned short
using namespace std;
const int inf = 1e9,MOD=1e9+7,N=3e5+5,MN=1e9+7;
void solve() {
int n,k,R;
cin>>n>>k>>R;
vector<int>v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
map<int,int>mp;
int have=0;
for(int i=0;i<R;i++){
int b,q;
cin>>b>>q;
mp[b]=q;
}
map<int,int>cur;
int l=0,r=0;
int mn=inf;
for(;r<n;r++){
cur[v[r]]++;
if(cur[v[r]]==mp[v[r]]){
have++;
}
while(have==R&&l<=r){
mn=min(mn,r-l+1);
if(cur[v[l]]==mp[v[l]]){
have--;
}
cur[v[l]]--;
l++;
}
}
if(mn==inf){
cout<<"impossible"<<endl;
}
else{
cout<<mn<<endl;
}
}
signed main() {
IOS;
// srand(time(NULL));
//freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int UwU=1;
// cin>>UwU;
for(int i=1;i<=UwU;i++) {
// cout<<"Case "<<i<<": "<<endl;
solve();
// cout<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
3 ms |
860 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
600 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
1884 KB |
Output is correct |
2 |
Correct |
11 ms |
1884 KB |
Output is correct |
3 |
Correct |
16 ms |
1884 KB |
Output is correct |
4 |
Correct |
14 ms |
1880 KB |
Output is correct |
5 |
Correct |
135 ms |
11800 KB |
Output is correct |
6 |
Correct |
13 ms |
1884 KB |
Output is correct |
7 |
Correct |
23 ms |
2036 KB |
Output is correct |
8 |
Correct |
271 ms |
26876 KB |
Output is correct |
9 |
Correct |
90 ms |
2904 KB |
Output is correct |
10 |
Correct |
17 ms |
1880 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
860 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
205 ms |
11996 KB |
Output is correct |
2 |
Correct |
192 ms |
9420 KB |
Output is correct |
3 |
Correct |
147 ms |
9276 KB |
Output is correct |
4 |
Correct |
11 ms |
1884 KB |
Output is correct |
5 |
Correct |
173 ms |
14408 KB |
Output is correct |
6 |
Correct |
355 ms |
24656 KB |
Output is correct |
7 |
Correct |
72 ms |
2908 KB |
Output is correct |
8 |
Correct |
120 ms |
4432 KB |
Output is correct |
9 |
Correct |
13 ms |
1880 KB |
Output is correct |
10 |
Correct |
11 ms |
1884 KB |
Output is correct |
11 |
Correct |
16 ms |
1884 KB |
Output is correct |
12 |
Correct |
15 ms |
1884 KB |
Output is correct |
13 |
Correct |
139 ms |
12012 KB |
Output is correct |
14 |
Correct |
13 ms |
1880 KB |
Output is correct |
15 |
Correct |
22 ms |
1884 KB |
Output is correct |
16 |
Correct |
259 ms |
27052 KB |
Output is correct |
17 |
Correct |
89 ms |
3004 KB |
Output is correct |
18 |
Correct |
18 ms |
1884 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
3 ms |
860 KB |
Output is correct |
23 |
Correct |
2 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |