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;
using vi = vector<int>;
using ll = long long;
using ii = pair<int, int>;
const int maxn = 2e5 + 5;
int A[maxn], B[maxn], N;
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 count(int l, int r) {
int ret = 0;
for(int i = 0; i < N; ++i) {
ret += l <= A[i] and B[i] <= r;
} return ret;
}
int can(int M, int K[]) {
for(ll i = 0, s = 0; i < M; ++i) {
if((s += K[i]) > N) return 0;
}
map<int, int> cnt;
for(int i = 0; i < M; ++i) {
cnt[K[i]] += K[i];
}
vector<ii> v;
for(auto x : cnt) {
v.emplace_back(x.first, x.second);
}
for(int i = 0; i < (int)v.size(); ++i) {
int s = 0, exc = 0;
for(int j = i; j < (int)v.size(); ++j) {
s += v[j].second;
if(i < j) exc += count(v[j-1].first+1, v[j].first-1);
if(N - count(1, v[i].first-1) - exc - count(v[j].first+1, N) < s) {
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... |