# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1049141 |
2024-08-08T13:56:19 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++17 |
|
323 ms |
31828 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define sst string
#define pb push_back
#define maxco 100000+5
#define lld long double
#define cha ios_base::sync_with_stdio(false);
#define ffl cout.flush();
#define phi acos(-1)
#define mr make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define pqin priority_queue<ll,vector<ll>,greater<>>
#define pqpair priority_queue<pair<ll,ll> ,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define pqpair2 priority_queue<pair<pair<ll,ll>,pair<ll,ll>>,vector<pair<pi,pair<ll,ll>>>,greater<pair<pi,pair<ll,ll>>>>
#define INF 1000000009
#define MAXN 1000006
#define pii pair<ll,ll>
#define mod 998244353
ll a[MAXN];
ll n,k,r;
map<ll,ll> nd;
map<ll,ll> cnt;
int main(){
cin>>n>>k>>r;
REP(i,1,n){
cin>>a[i];
}
REP(i,1,r){
ll b,c;
cin>>b>>c;
nd[b]=c;
}
ll ans=1e18;
set<ll> st;
ll l=1;
for(ll i=1;i<=n;i++){
cnt[a[i]]++;
if(cnt[a[i]]==nd[a[i]] && nd[a[i]]>0){
st.insert(a[i]);
}
if(st.size()==r){
while(l<i && cnt[a[l]]>nd[a[l]]){
cnt[a[l]]--;
l++;
}
ans=min(ans,i-l+1);
}
}
if(ans==1e18)cout<<"impossible"<<endl;
else cout<<ans<<endl;
}
Compilation message
dna.cpp: In function 'int main()':
dna.cpp:46:21: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
46 | if(st.size()==r){
| ~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
440 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
444 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 |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
860 KB |
Output is correct |
5 |
Correct |
2 ms |
660 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 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 |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2648 KB |
Output is correct |
2 |
Correct |
16 ms |
2652 KB |
Output is correct |
3 |
Correct |
19 ms |
2652 KB |
Output is correct |
4 |
Correct |
17 ms |
2664 KB |
Output is correct |
5 |
Correct |
140 ms |
12624 KB |
Output is correct |
6 |
Correct |
17 ms |
2648 KB |
Output is correct |
7 |
Correct |
25 ms |
2652 KB |
Output is correct |
8 |
Correct |
182 ms |
28756 KB |
Output is correct |
9 |
Correct |
93 ms |
4436 KB |
Output is correct |
10 |
Correct |
20 ms |
2908 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 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 |
600 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 |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 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 |
212 ms |
16364 KB |
Output is correct |
2 |
Correct |
185 ms |
12732 KB |
Output is correct |
3 |
Correct |
148 ms |
10900 KB |
Output is correct |
4 |
Correct |
20 ms |
2652 KB |
Output is correct |
5 |
Correct |
169 ms |
14948 KB |
Output is correct |
6 |
Correct |
323 ms |
31828 KB |
Output is correct |
7 |
Correct |
79 ms |
5012 KB |
Output is correct |
8 |
Correct |
127 ms |
6860 KB |
Output is correct |
9 |
Correct |
16 ms |
2908 KB |
Output is correct |
10 |
Correct |
16 ms |
2908 KB |
Output is correct |
11 |
Correct |
19 ms |
2908 KB |
Output is correct |
12 |
Correct |
21 ms |
2908 KB |
Output is correct |
13 |
Correct |
138 ms |
13780 KB |
Output is correct |
14 |
Correct |
18 ms |
2904 KB |
Output is correct |
15 |
Correct |
24 ms |
3164 KB |
Output is correct |
16 |
Correct |
187 ms |
28748 KB |
Output is correct |
17 |
Correct |
89 ms |
4440 KB |
Output is correct |
18 |
Correct |
21 ms |
2908 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
3 ms |
984 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 |