Submission #1049139

#TimeUsernameProblemLanguageResultExecution timeMemory
1049139vjudge1 Martian DNA (BOI18_dna)C++17
0 / 100
204 ms16528 KiB
#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<<-1<<endl; else cout<<ans<<endl; }

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...