Submission #947576

# Submission time Handle Problem Language Result Execution time Memory
947576 2024-03-16T13:20:43 Z sondos225 Martian DNA (BOI18_dna) C++17
100 / 100
27 ms 5456 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define yes "YES"
#define no "NO"
#define bigg INT_MAX
#define debug(x) cout<<(#x)<<" = " <<x<<endl;
#define all(x) x.begin(),x.end()
#define sz size()
#define nn '\n'
#define mms(x,y) memset(x,y,sizeof(x))
#define forr(i,j,n) for (int i=j; i<n; i++)
#define forn(i,j,n) for (int i=j; i>n; i--)
#define fi first
#define se second
#define la "LA"
#define cinn(x,y) for(int i=0; i<y; i++) cin>>x[i];
#define pii pair<int,int>
signed main()
{
//    #ifndef LOCAL
//    freopen("lifeguards.in","r",stdin);
//    freopen("lifeguards.out","w", stdout);
//    #endif
    fast
    int n,k,r;
    cin>>n >>k >>r;
    int a[n];
    forr(i,0,n)
    {
        cin>>a[i];
    }
    int freq[k]={ };
    bool req[k]={ };
    forr(i,0,r)
    {
        int x,y;
        cin>>x >>y;
        freq[x]=y;
        req[x]=1;
    }
    int j=0;
    int c=r;
    int ans=bigg;
    forr(i,0,n)
    {
        int x=a[i];
        freq[x]--;
        if (c!=0){
//        if (freq[x])
//        {

            if (freq[x]==0) c--;
            //freq[x]=-1;
//        }
        }
        if (c==0)
        {
           for(;j<=i;j++)
           {
               if (req[a[j]] && freq[a[j]]==0) break;
               freq[a[j]]++;
           }
           //cout<<i<<' '<<j<<endl;
           ans=min(ans,i-j+1);
        }
    }
    if (ans==bigg) cout<<"impossible";
    else cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 452 KB Output is correct
6 Correct 0 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 344 KB Output is correct
# 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 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 500 KB Output is correct
6 Correct 1 ms 424 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 0 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 460 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1884 KB Output is correct
2 Correct 11 ms 2396 KB Output is correct
3 Correct 10 ms 2388 KB Output is correct
4 Correct 9 ms 2396 KB Output is correct
5 Correct 13 ms 3676 KB Output is correct
6 Correct 9 ms 2404 KB Output is correct
7 Correct 9 ms 2396 KB Output is correct
8 Correct 16 ms 4768 KB Output is correct
9 Correct 12 ms 2908 KB Output is correct
10 Correct 10 ms 2396 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 600 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 452 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2652 KB Output is correct
2 Correct 20 ms 4048 KB Output is correct
3 Correct 16 ms 3928 KB Output is correct
4 Correct 9 ms 2396 KB Output is correct
5 Correct 22 ms 5052 KB Output is correct
6 Correct 27 ms 5456 KB Output is correct
7 Correct 12 ms 2908 KB Output is correct
8 Correct 15 ms 3280 KB Output is correct
9 Correct 9 ms 2288 KB Output is correct
10 Correct 9 ms 2396 KB Output is correct
11 Correct 10 ms 2396 KB Output is correct
12 Correct 12 ms 2392 KB Output is correct
13 Correct 13 ms 3676 KB Output is correct
14 Correct 9 ms 2396 KB Output is correct
15 Correct 9 ms 2396 KB Output is correct
16 Correct 16 ms 4816 KB Output is correct
17 Correct 12 ms 2904 KB Output is correct
18 Correct 9 ms 2396 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 464 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 600 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 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