Submission #937806

# Submission time Handle Problem Language Result Execution time Memory
937806 2024-03-04T13:48:43 Z danikoynov Teams (IOI15_teams) C++14
21 / 100
4000 ms 18096 KB
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;

struct segment
{
    int l, r;

    segment(int _l = 0, int _r = 0)
    {
        l = _l;
        r = _r;
    }
};

int n;
segment s[maxn];
void init(int N, int A[], int B[])
{
    n = N;
    for (int i = 1; i <= n; i ++)
        s[i] = segment(A[i - 1], B[i - 1]);
}

struct event
{
    int x, t, id;

    event(int _x = 0, int _t = 0, int _id = 0)
    {
        x = _x;
        t = _t;
        id = _id;
    }

};

bool cmp_event(event e1, event e2)
{
    if (e1.x != e2.x)
        return e1.x < e2.x;
    return e1.t < e2.t;
}

int dp[maxn];


int can(int M, int K[])
{

    for (int i = 0; i < M; i ++)
    {
        dp[i] = 0;
    }

    sort(K, K + M);
    for (int i = 0; i < M; i ++)
    {

    for (int j = 1; j <= n; j ++)
        if (s[j].l <= K[i] && s[j].r >= K[i])
        dp[i] ++;
    dp[i] -= K[i];

    for (int j = 0; j < i; j ++)
    {
        int cnt = 0;
        for (int d = 1; d <= n; d ++)
        {
            if (s[d].l <= K[j] && s[d].r >= K[j])
                continue;
            if (s[d].l <= K[i] && s[d].r >= K[i])
                cnt ++;
        }
        dp[i] = min(dp[i], dp[j] + cnt - K[i]);
    }
    if (dp[i] < 0)
        return 0;
    }

    return 1;


    /**vector < event > events;
    for (int i = 0; i < M; i ++)
    {
        events.push_back(event(K[i], 0, -1));
    }
    for (int i = 1; i <= n; i ++)
    {
        events.push_back(event(s[i].l, -1, i));
        events.push_back(event(s[i].r, 1, i));
    }

    sort(events.begin(), events.end(), cmp_event);

    set < pair < int, int > > act;
    for (event cur : events)
    {
        if (cur.t == -1)
        {
            act.insert({s[cur.id].r, cur.id});
        }
        else
        if (cur.t == 1)
        {
            if (act.find({s[cur.id].r, cur.id}) != act.end())
                act.erase({s[cur.id].r, cur.id});
        }
        else
        {
            if (act.size() < cur.x)
            {
                return 0;
            }
            for (int d = 0; d < cur.x; d ++)
                act.erase(act.begin());
        }
    }
    return 1;*/
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5980 KB Output is correct
2 Correct 1 ms 5980 KB Output is correct
3 Correct 2 ms 5980 KB Output is correct
4 Correct 2 ms 5980 KB Output is correct
5 Correct 2 ms 5980 KB Output is correct
6 Correct 2 ms 6232 KB Output is correct
7 Correct 5 ms 5980 KB Output is correct
8 Correct 3 ms 6132 KB Output is correct
9 Correct 2 ms 5980 KB Output is correct
10 Correct 3 ms 6132 KB Output is correct
11 Correct 2 ms 5980 KB Output is correct
12 Correct 10 ms 5980 KB Output is correct
13 Correct 5 ms 6132 KB Output is correct
14 Correct 3 ms 5980 KB Output is correct
15 Correct 2 ms 5980 KB Output is correct
16 Correct 2 ms 6068 KB Output is correct
17 Correct 2 ms 5976 KB Output is correct
18 Correct 2 ms 6132 KB Output is correct
19 Correct 2 ms 5980 KB Output is correct
20 Correct 2 ms 5980 KB Output is correct
21 Correct 2 ms 5980 KB Output is correct
22 Correct 2 ms 5980 KB Output is correct
23 Correct 2 ms 5980 KB Output is correct
24 Correct 2 ms 5980 KB Output is correct
25 Correct 2 ms 5980 KB Output is correct
26 Correct 2 ms 6132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8028 KB Output is correct
2 Correct 6 ms 8028 KB Output is correct
3 Correct 7 ms 7876 KB Output is correct
4 Correct 8 ms 8720 KB Output is correct
5 Execution timed out 4037 ms 7516 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 116 ms 8924 KB Output is correct
2 Correct 182 ms 8784 KB Output is correct
3 Execution timed out 4008 ms 9076 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 848 ms 18072 KB Output is correct
2 Correct 846 ms 18096 KB Output is correct
3 Execution timed out 4018 ms 17096 KB Time limit exceeded
4 Halted 0 ms 0 KB -