Submission #945432

# Submission time Handle Problem Language Result Execution time Memory
945432 2024-03-13T19:07:46 Z rahidilbayramli Martian DNA (BOI18_dna) C++17
40 / 100
2000 ms 18204 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll sz = 2e5+5;
vl g[sz];
ll grid[15][sz];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tests = 1;
    //cin >> tests;
    while(tests--)
    {
        ll n, k, r, i, j, ans = LLONG_MAX;
        cin >> n >> k >> r;
        vl v(n+5);
        map<ll, ll>mp;
        for(i = 1; i <= n; i++)
            cin >> v[i];
        vl vect;
        for(i = 1; i <= r; i++)
        {
            ll x, y;
            cin >> x >> y;
            mp[x] = y;
            vect.pb(x);
        }
        for(i = 1; i <= n; i++)
        {
            map<ll, ll>mp2;
            for(j = i; j <= n; j++)
            {
                mp2[v[j]]++;
                bool possible = true;
                for(auto u : vect)
                {
                    if(mp2[u] < mp[u])
                    {
                        possible = false;
                        break;
                    }
                }
                if(possible)
                    ans = min(ans, j - i + 1);
            }
        }
        if(ans == LLONG_MAX)
            cout << "impossible\n";
        else
            cout << ans << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 2 ms 5720 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5724 KB Output is correct
7 Correct 2 ms 5720 KB Output is correct
8 Correct 2 ms 5724 KB Output is correct
9 Correct 3 ms 5724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 5844 KB Output is correct
2 Correct 251 ms 5972 KB Output is correct
3 Correct 1198 ms 6068 KB Output is correct
4 Correct 1167 ms 6180 KB Output is correct
5 Correct 1297 ms 6024 KB Output is correct
6 Correct 689 ms 5724 KB Output is correct
7 Correct 2 ms 5724 KB Output is correct
8 Correct 2 ms 5724 KB Output is correct
9 Correct 2 ms 5724 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 2 ms 5720 KB Output is correct
12 Correct 2 ms 5724 KB Output is correct
13 Correct 2 ms 5724 KB Output is correct
14 Correct 2 ms 5724 KB Output is correct
15 Correct 2 ms 5724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 7260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2056 ms 18204 KB Time limit exceeded
2 Halted 0 ms 0 KB -