이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |