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;
const int maxN = 5e5 + 20;
const int maxM = 2e5 + 20;
int A[maxN];
int B[maxN];
int N;
int get(int lx, int rx, int ly) {
if (lx > rx) {
return 0;
}
int cnt = 0;
for (int i = 0; i < N; i++) {
if (lx <= A[i] && A[i] <= rx && B[i] >= ly) {
cnt++;
}
}
return cnt;
}
void init(int _N, int _A[], int _B[]) {
N = _N;
for (int i = 0; i < N; i++) {
A[i] = _A[i];
B[i] = _B[i];
}
}
int dp[maxM];
int can(int M, int K[]) {
long long sum = 0;
for (int i = 0; i < M; i++) {
sum += K[i];
}
if (sum > N) {
return 0;
}
sort(K, K + M);
for (int i = 0; i < M; i++) {
dp[i] = get(1, K[i], K[i]) - K[i];
for (int j = 0; j < i; j++) {
dp[i] = min(dp[i], dp[j] + get(K[j] + 1, K[i], K[i]) - K[i]);
}
if (dp[i] < 0) {
return false;
}
}
return true;
}
# | 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... |