This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct segment
{
ll l, r;
segment(ll _l = 0, ll _r = 0)
{
l = _l;
r = _r;
}
};
const ll maxn = 5e5 + 10;
ll n;
segment s[maxn];
void init(int N, int A[], int B[])
{
n = N;
for (ll i = 1; i <= n; i ++)
{
s[i] = segment(A[i - 1], B[i - 1]);
}
}
ll zeta(ll a, ll b)
{
ll cnt = 0;
for (ll i = 1; i <= n; i ++)
{
if (s[i].l <= a && s[i].r >= a)
continue;
if (s[i].l <= b && s[i].r >= b)
cnt ++;
}
return cnt;
}
ll dp[maxn];
int can(int M, int K[])
{
for (ll i = 0; i < M; i ++)
{
dp[i] = zeta(0, K[i]) - K[i];
for (ll j = 0; j < i; j ++)
{
dp[i] = min(dp[i], dp[j] + zeta(K[j], K[i]) - K[i]);
}
if (dp[i] < 0)
return 0;
}
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |