This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* [Author : Hoang Duy Vu] - THPT Chuyen Nguyen Du */
//#pragma GCC optimize(" unroll-loops")
//#pragma gcc optimize("Ofast")
//#pragma GCC optimization("Ofast")
//#pragma optimize(Ofast)
#include "teams.h"
#include <bits/stdc++.h>
#define All(x) (x).begin(),(x).end()
#define ll long long
#define C make_pair
#define fi first
#define se second
#define two second.first
#define thr second.second
#define TASK "txt"
using namespace std;
template<typename T> bool maximize(T &res, const T &val) {
if (res < val) { res = val; return true; } return false; }
template<typename T> bool minimize(T &res, const T &val) {
if (res > val) { res = val; return true; } return false; }
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int LOG = 20;
const int INF = 1e9 + 7;
const ll LNF = 1e18 + 7;
const int mod = 1e9 + 7;
const int Nx = 1e5 + 100;
multiset <int> s;
ii a[Nx];
vector <int> in[Nx] , out[Nx];
int n;
int m;
void init(int N, int A[], int B[]) {
n = N;
for (int i = 0 ; i < n ; i++)
{
in[B[i]].push_back(A[i]);
out[A[i] - 1].push_back(A[i]);
}
}
int can(int M, int K[]) {
int m = M;
sort(K,K+m);
s.clear();
int r = m - 1;
for (int i = n ; i >= 0 ; i--)
{
for (int v : in[i]) s.insert(v);
for (int v : out[i]) s.erase(s.find(v));
while (r >= 0 && K[r] == i)
{
if (s.size() < i) return 0;
for (int j = 1 ; j <= i ; j++)
{
auto x = s.end();
x--;
s.erase(s.find(*x));
}
r--;
}
}
return 1;
}
// int main()
// {
// ios_base::sync_with_stdio(0);
// cin.tie(NULL); cout.tie(NULL);
// if(fopen(TASK".inp", "r")){
// freopen(TASK".inp","r",stdin);
// freopen(TASK".out","w",stdout);
// }
// return 0;
// }
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:46:9: warning: declaration of 'm' shadows a global declaration [-Wshadow]
46 | int m = M;
| ^
teams.cpp:34:5: note: shadowed declaration is here
34 | int m;
| ^
teams.cpp:59:26: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
59 | if (s.size() < i) return 0;
| ~~~~~~~~~^~~
# | 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... |