# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
458059 |
2021-08-07T23:53:22 Z |
ZaZo_ |
Martian DNA (BOI18_dna) |
C++14 |
|
570 ms |
11848 KB |
//Sorry but iam targeting IOI :))
//NEVER LOSE HOPE
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define endl "\n"
#define ceil(a,b) (a+(b-1))/b
#define all(v) v.begin(),v.end()
#define int long long int
#define Hidden ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=3e4+10,mod = 1e9+7;
int32_t main(){
int n,k,rr;
cin>>n>>k>>rr;
int arr[n];
map<int,int>mp,req,dif;
set<int>st;
for(int i = 0 ; i < n ; i ++)
{
cin>>arr[i];
}
int flg=0;
for(int i = 0 ; i < rr ; i ++)
{
int x,y;
cin>>x>>y;
if(mp[x]<y) flg=1;
req[x]=y;
}
int l=0,r=0,ans=INT_MAX,cnt=0;
while(l<=r)
{
while(r<n && (mp.size()<k || cnt<req.size()) )
{
mp[arr[r]]++;
if(req.count(arr[r]) && mp[arr[r]]==req[arr[r]]) cnt++;
r++;
}
if(cnt==req.size())
ans=min(ans,r-l);
mp[arr[l]]--;
if(req.count(arr[l])&&req[arr[l]]>mp[arr[l]]) cnt--;
if(mp[arr[l]]==0) mp.erase(arr[l]);
l++;
}
if(ans==INT_MAX)
{
cout<<"impossible"<<endl;
return 0;
}
cout<<ans<<endl;
}
Compilation message
dna.cpp: In function 'int32_t main()':
dna.cpp:34:28: warning: comparison of integer expressions of different signedness: 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
34 | while(r<n && (mp.size()<k || cnt<req.size()) )
| ~~~~~~~~~^~
dna.cpp:34:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | while(r<n && (mp.size()<k || cnt<req.size()) )
| ~~~^~~~~~~~~~~
dna.cpp:40:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if(cnt==req.size())
| ~~~^~~~~~~~~~~~
dna.cpp:23:7: warning: variable 'flg' set but not used [-Wunused-but-set-variable]
23 | int flg=0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
1780 KB |
Output is correct |
2 |
Correct |
43 ms |
1828 KB |
Output is correct |
3 |
Correct |
48 ms |
1740 KB |
Output is correct |
4 |
Correct |
47 ms |
1828 KB |
Output is correct |
5 |
Incorrect |
208 ms |
6836 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
570 ms |
11848 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |