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"
using namespace std;
const int INF = INT32_MAX;
const int batch = 750;
vector<pair<int, int>> arr;
void init(int N, int A[], int B[]) {
for(int i = 0; i < N; i++) {
int U = A[i], V = B[i];
arr.push_back({U, V});
}
}
int can(int M, int K[]) {
int N = arr.size();
vector<pair<int, int>> A(M);
for(int l = 0; l < M; l++) A[l].second = l, A[l].first = 0;
for(int l = 0; l < N; l++) {
int U = arr[l].first, V = arr[l].second;
for(int i = 0; i < M; i++) {
if(K[i] >= U && K[i] <= V)
A[i].first++;
}
}
sort(A.begin(), A.end()); int res = 1;
vector<bool> vis(N, 0);
for(int i = 0; i < M; i++) {
int cur = 0;
for(int j = 0; j < N && cur < K[A[i].second]; j++) {
if(vis[j]) continue;
int U = arr[j].first, V = arr[j].second;
if(K[A[i].second] >= U && K[A[i].second] <= V)
cur++, vis[j] = 1;
}
res &= (cur == K[A[i].second]);
}
return res;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:19:33: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
19 | int N = arr.size();
| ~~~~~~~~^~
# | 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... |