Submission #947985

# Submission time Handle Problem Language Result Execution time Memory
947985 2024-03-17T11:09:23 Z Zena_Hossam Martian DNA (BOI18_dna) C++14
0 / 100
224 ms 16560 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
using namespace std;
#define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ll double

#define ll1 long long
#define F first
#define S second
#define sz size()
#define all(s) s.begin(),s.end()
#define all1(s) s.rbegin(),s.rend()
int main()
{
    //freopen("stdin.in","r",stdin);freopen("stdout.out","w",stdout);
    int T=1;
    //cin>>T;ll oo=0;
    while(T--)
    {
        ll n,k,z;
        cin>>n>>k>>z;
        ll arr[n];
        for(ll i=0;i<n;i++){
            cin>>arr[i];
        }
        map<ll,ll>m,d;
        for(ll i=0;i<z;i++){
            ll a,b;
            cin>>a>>b;
            m[a]=b;
        }ll c=k-z;ll mn=1e18;ll o=0;
        for(ll i=0;i<n;i++){
           d[arr[i]]++;
            if(d[arr[i]]==m[arr[i]])c++;
            while(c==k){//cout<<i<<" "<<o<<"\n";
                mn=min(mn,(i-o+1));d[arr[o]]--;
                if(d[arr[o]]<m[arr[o]])c--;
                o++;

            }
        }cout<<mn;
    }
}
# 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 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 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 3 ms 860 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2364 KB Output is correct
2 Correct 28 ms 2376 KB Output is correct
3 Correct 32 ms 2396 KB Output is correct
4 Correct 28 ms 2648 KB Output is correct
5 Correct 167 ms 12976 KB Output is correct
6 Correct 28 ms 2140 KB Output is correct
7 Incorrect 40 ms 2396 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 221 ms 13652 KB Output is correct
2 Correct 224 ms 11088 KB Output is correct
3 Correct 168 ms 10576 KB Output is correct
4 Correct 26 ms 2140 KB Output is correct
5 Incorrect 205 ms 16560 KB Output isn't correct
6 Halted 0 ms 0 KB -