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;
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
vector<pii> stud;
int n;
struct cmp
{
bool operator()(pii a, pii b)
{
if(a.fi != b.fi)
return a.fi > b.fi;
return a.fi > b.fi;
}
};
void init(int N, int A[], int B[])
{
n = N;
for(int i = 0; i<n; i++)
{
stud.pb(mp(A[i], B[i]));
}
sort(stud.begin(), stud.end(), cmp());
}
int can(int M, int K[])
{
sort(K, K+M);
pii need[M];
int dsleft[M];
for(int i = 0; i<M; i++)
{
need[i] = mp(K[M-1-i], K[M-1-i]);
dsleft[i] = i;
}
int sum;
for(int i = 0; i<n; i++)
{
//cout<<stud[i].fi<<" "<<stud[i].se<<endl;
for(int j = 0; j<M; j++)
{
if(need[j].se == 0)
continue;
if(stud[i].fi <= need[j].fi && need[j].fi <= stud[i].se)
{
need[j].se--;
break;
}
}
}
int ans = 1;
for(int i = 0; i<M; i++)
{
if(need[i].se != 0)
ans = 0;
}
return ans;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:40:9: warning: variable 'dsleft' set but not used [-Wunused-but-set-variable]
40 | int dsleft[M];
| ^~~~~~
teams.cpp:46:9: warning: unused variable 'sum' [-Wunused-variable]
46 | int sum;
| ^~~
# | 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... |