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 <bits/stdc++.h>
#include "teams.h"
#define P pair<int,int>
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
const int maxn = 110; // WARNING SMALL N
int n;
vector<P>intervals;
int cnt[maxn][maxn], used[maxn];
class node {
public:
int sum;
node *leftchild, *rightchild;
node(int _sum) {
sum = _sum;
leftchild = rightchild = NULL;
}
node(node *a, node *b) {
sum = a->sum + b->sum;
leftchild = a; rightchild = b;
}
};
node *build(int li=1, int ri=n) {
if(li == ri) return new node(0);
else {
int mid = (li + ri) / 2;
return new node(build(li, mid), build(mid+1, ri));
}
}
node* insert_number(node *curr, int position, int val, int li=1, int ri=n) {
if(li == ri) {
curr->sum += val;
return curr;
}
else {
int mid = (li + ri) / 2;
if(position <= mid) return new node(insert_number(curr->leftchild, position, val, li, mid), curr->rightchild);
else return new node(curr->leftchild, insert_number(curr->rightchild, position, val, mid+1, ri));
}
}
void init(int N, int A[], int B[]) {
n = N;
for(int i=1;i<=n;i++) {
for(int j=0;j<n;j++) {
if(i >= A[j] && i <= B[j]) {
cnt[i][B[j]]++;
}
}
}
}
int can(int M, int K[]) {
memset(used,0,sizeof(used));
sort(K, K + M);
int marked = 0;
for(int i=0;i<M;i++) {
marked = 0;
for(int j=1;j<=n;j++) {
//if(cnt[K[i]][j] <= used[j]) continue;
int diff = cnt[K[i]][j] - used[j];
diff = min(diff, K[i] - marked);
used[j] += diff;
marked += diff;
if(marked == K[i]) break;
}
if(marked != K[i]) 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... |