답안 #947987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947987 2024-03-17T11:14:45 Z Zena_Hossam Martian DNA (BOI18_dna) C++14
100 / 100
379 ms 28284 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++;

            }
        }
        if(mn==1e18)cout<<"impossible";
        else
        cout<<mn;
    }
}
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 344 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 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1884 KB Output is correct
2 Correct 25 ms 1968 KB Output is correct
3 Correct 31 ms 1884 KB Output is correct
4 Correct 28 ms 1884 KB Output is correct
5 Correct 163 ms 11952 KB Output is correct
6 Correct 27 ms 1884 KB Output is correct
7 Correct 37 ms 1880 KB Output is correct
8 Correct 297 ms 28284 KB Output is correct
9 Correct 112 ms 3956 KB Output is correct
10 Correct 33 ms 2396 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 648 KB Output is correct
14 Correct 3 ms 860 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 11800 KB Output is correct
2 Correct 183 ms 9480 KB Output is correct
3 Correct 174 ms 9480 KB Output is correct
4 Correct 25 ms 1884 KB Output is correct
5 Correct 209 ms 14504 KB Output is correct
6 Correct 379 ms 26708 KB Output is correct
7 Correct 97 ms 3924 KB Output is correct
8 Correct 141 ms 5652 KB Output is correct
9 Correct 27 ms 2140 KB Output is correct
10 Correct 26 ms 2140 KB Output is correct
11 Correct 30 ms 2396 KB Output is correct
12 Correct 29 ms 2400 KB Output is correct
13 Correct 167 ms 13136 KB Output is correct
14 Correct 28 ms 2136 KB Output is correct
15 Correct 40 ms 2396 KB Output is correct
16 Correct 267 ms 28244 KB Output is correct
17 Correct 111 ms 3924 KB Output is correct
18 Correct 32 ms 2140 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 3 ms 728 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct