Submission #458058

#TimeUsernameProblemLanguageResultExecution timeMemory
458058ZaZo_ Martian DNA (BOI18_dna)C++14
0 / 100
699 ms11852 KiB
//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() && mp.size()>=k) 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 (stderr)

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() && mp.size()>=k)
      |        ~~~^~~~~~~~~~~~
dna.cpp:40:36: 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]
   40 |     if(cnt==req.size() && mp.size()>=k)
      |                           ~~~~~~~~~^~~
dna.cpp:23:7: warning: variable 'flg' set but not used [-Wunused-but-set-variable]
   23 |   int flg=0;
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...