Submission #927069

# Submission time Handle Problem Language Result Execution time Memory
927069 2024-02-14T08:24:52 Z vjudge1 Martian DNA (BOI18_dna) C++17
40 / 100
2000 ms 6232 KB
/*
no more temmy :(
*/

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #include<icecream.hpp>
// using namespace icecream;
#define ll long long
#define int ll
#define ld long double
#define y1 cheza
// mt19937 rng(1983413);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=2e5+100;
const int M=1e3+1;
const int B=317;
const int mod=1e9+7;
const int INF=1e18;
const int lg=64;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const double eps=1e-9;
int n,k,r;
int a[N];
int b[N],q[N];
int cnt[N];
void test(){
    cin>>n>>k>>r;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=r;i++){
        cin>>b[i]>>q[i];
    }
    int ans=INF;
    for(int i=1;i<=n;i++){
        for(int j=0;j<k;j++){
            cnt[j]=0;
        }
        for(int j=i;j<=n;j++){
            cnt[a[j]]++;
            bool ok=1;
            for(int w=1;w<=r;w++){
                if(cnt[b[w]]<q[w]){
                    ok=0;
                }
            }
            if(ok){
                ans=min(ans,j-i+1);
            }
        }
    }
    if(ans>=INF){
        cout<<"impossible\n";
        return;
    }
    cout<<ans<<'\n';

}
/*
*/  
 
signed main(){

    // ic.prefix("debug->| ");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    long long t2=1;
    //  cin>>t2;
    for(int i=1;i<=t2;i++){
        test();
    }
    
    return 0;
 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 4440 KB Output is correct
2 Correct 48 ms 4588 KB Output is correct
3 Correct 47 ms 4440 KB Output is correct
4 Correct 49 ms 4440 KB Output is correct
5 Correct 48 ms 4444 KB Output is correct
6 Correct 50 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4452 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2084 ms 6008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2033 ms 6232 KB Time limit exceeded
2 Halted 0 ms 0 KB -