답안 #993889

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993889 2024-06-06T18:18:33 Z AndrijaM Martian DNA (BOI18_dna) C++14
100 / 100
26 ms 8620 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxn=2e5+10;
const int mod=1e9+7;

int m[maxn];
int cnt[maxn];
int K[maxn];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(m,-1,sizeof m);
    ///freopen("prieteni.in","r",stdin);
    ///freopen("prieteni.out","w",stdout);
    int n,k,r;
    cin>>n>>k>>r;
    int x[n];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        K[x[i]]++;
    }
    bool T=true;
    for(int i=0;i<r;i++)
    {
        int koj,kol;
        cin>>koj>>kol;
        m[koj]=kol;
        if(K[koj]<m[koj])
        {
            T=false;
        }
    }
    if(!T)
    {
        cout<<"impossible"<<endl;
        return 0;
    }
    int ok=0;
    int ans=n;
    int j=-1;
    for(int i=0;i<n;i++)
    {
        cnt[x[i]]++;
        if(cnt[x[i]]==m[x[i]])
        {
            ok++;
        }
        if(ok==r)
        {
            while(j+1<i && cnt[x[j+1]]!=m[x[j+1]])
            {
                cnt[x[j+1]]--;
                j++;
            }
            ans=min(ans, i-(j+1)+1);
        }
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2908 KB Output is correct
2 Correct 1 ms 2908 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 0 ms 2908 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2908 KB Output is correct
2 Correct 1 ms 2908 KB Output is correct
3 Correct 1 ms 2904 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2908 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 1 ms 2928 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
14 Correct 1 ms 2908 KB Output is correct
15 Correct 1 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4492 KB Output is correct
2 Correct 9 ms 4300 KB Output is correct
3 Correct 9 ms 4444 KB Output is correct
4 Correct 9 ms 4444 KB Output is correct
5 Correct 12 ms 6720 KB Output is correct
6 Correct 8 ms 4444 KB Output is correct
7 Correct 8 ms 4444 KB Output is correct
8 Correct 16 ms 7772 KB Output is correct
9 Correct 14 ms 5468 KB Output is correct
10 Correct 9 ms 4700 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
14 Correct 1 ms 2904 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
16 Correct 1 ms 2932 KB Output is correct
17 Correct 1 ms 2908 KB Output is correct
18 Correct 1 ms 2908 KB Output is correct
19 Correct 1 ms 2908 KB Output is correct
20 Correct 1 ms 3160 KB Output is correct
21 Correct 1 ms 2908 KB Output is correct
22 Correct 1 ms 2908 KB Output is correct
23 Correct 1 ms 2908 KB Output is correct
24 Correct 1 ms 2904 KB Output is correct
25 Correct 1 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 6492 KB Output is correct
2 Correct 18 ms 6492 KB Output is correct
3 Correct 15 ms 6492 KB Output is correct
4 Correct 10 ms 4444 KB Output is correct
5 Correct 26 ms 6488 KB Output is correct
6 Correct 23 ms 8620 KB Output is correct
7 Correct 13 ms 5468 KB Output is correct
8 Correct 14 ms 5980 KB Output is correct
9 Correct 10 ms 4684 KB Output is correct
10 Correct 9 ms 4696 KB Output is correct
11 Correct 10 ms 4852 KB Output is correct
12 Correct 9 ms 4700 KB Output is correct
13 Correct 13 ms 7772 KB Output is correct
14 Correct 9 ms 5180 KB Output is correct
15 Correct 10 ms 4956 KB Output is correct
16 Correct 18 ms 7728 KB Output is correct
17 Correct 13 ms 5496 KB Output is correct
18 Correct 9 ms 4872 KB Output is correct
19 Correct 1 ms 2904 KB Output is correct
20 Correct 1 ms 2908 KB Output is correct
21 Correct 1 ms 2920 KB Output is correct
22 Correct 1 ms 2908 KB Output is correct
23 Correct 1 ms 2908 KB Output is correct
24 Correct 1 ms 2908 KB Output is correct
25 Correct 1 ms 2908 KB Output is correct
26 Correct 1 ms 2908 KB Output is correct
27 Correct 1 ms 2908 KB Output is correct
28 Correct 1 ms 2908 KB Output is correct
29 Correct 1 ms 2904 KB Output is correct
30 Correct 1 ms 2904 KB Output is correct
31 Correct 1 ms 2908 KB Output is correct
32 Correct 1 ms 2908 KB Output is correct
33 Correct 1 ms 2908 KB Output is correct