Submission #1049132

# Submission time Handle Problem Language Result Execution time Memory
1049132 2024-08-08T13:48:29 Z vjudge1 Martian DNA (BOI18_dna) C++17
0 / 100
211 ms 17232 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;
int main(){
    cin>>n>>k>>r;
    map<ll,ll> cnt;
    REP(i,1,n){
        cin>>a[i];
    }
    REP(i,1,r){
        ll b,c;
        cin>>b>>c;
        nd[b]=c;
    }
    REP(i,0,k){
        if(!nd[i])nd[i]=-1;
    }
    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]]){
            st.insert(a[i]);
        }
        if(st.size()==r){
            while(l<i && cnt[a[l]]-1>=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

dna.cpp: In function 'int main()':
dna.cpp:49: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]
   49 |         if(st.size()==r){
      |            ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 3 ms 968 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 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2656 KB Output is correct
2 Correct 17 ms 2908 KB Output is correct
3 Correct 20 ms 3096 KB Output is correct
4 Correct 18 ms 2904 KB Output is correct
5 Correct 184 ms 13736 KB Output is correct
6 Correct 18 ms 2908 KB Output is correct
7 Incorrect 26 ms 3248 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 211 ms 16208 KB Output is correct
2 Correct 181 ms 14540 KB Output is correct
3 Correct 158 ms 12364 KB Output is correct
4 Correct 16 ms 2908 KB Output is correct
5 Incorrect 177 ms 17232 KB Output isn't correct
6 Halted 0 ms 0 KB -