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;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define F0R(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1;i>=a;--i)
#define R0F(i,b) ROF(i,0,b)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define pb push_back
#define sz(x) int(x.size())
int const N=1e5+3;
int A[N],B[N];
int n;
pii stu[N];
bool used[N];
void init(int n1, int A1[], int B1[]) {
n=n1;
F0R(i,n)
{
A[i]=A1[i];
B[i]=B1[i];
stu[i]={A[i],B[i]};
}
sort(stu,stu+n);
}
int can(int m, int K[]) {
sort(K,K+m);
fill(used,used+n,0);
R0F(i,m)
{
bool ok=0;
int cnt=0;
R0F(sta,K[i]+1)
{
int idex=lower_bound(stu,stu+n,pii{sta,-1})-stu;
int edex=upper_bound(stu,stu+n,pii{sta,1e9})-stu;
FOR(k,idex,edex)
{
if(used[k])continue;
if(stu[k].se>=K[i])
{
++cnt;
used[k]=1;
if(cnt==K[i])
{
ok=1;
break;
}
}
}
if(ok)break;
}
if(!ok)return 0;
}
return 1;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:49:47: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
49 | int idex=lower_bound(stu,stu+n,pii{sta,-1})-stu;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
teams.cpp:50:48: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
50 | int edex=upper_bound(stu,stu+n,pii{sta,1e9})-stu;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# | 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... |