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>
#define pb push_back
using namespace std;
#include "teams.h"
vector<pair<int, int> > st;
bool comp(pair<int, int> p1, pair<int, int> p2){
if(p1.second == p2.second) return (p1.first < p2.first);
else return (p1.second < p2.second);
}
void init(int N, int A[], int B[]){
for(int i = 0; i < N; i++){
st.pb({A[i], B[i]});
}
sort(st.begin(), st.end(), comp);
}
int can(int M, int K[]) {
sort(K, K + M);
vector<int> cnt(M);
for(int i = 0; i < st.size(); i++){
auto starti = lower_bound(K, K + M, st[i].first) - K;
if(starti >= M) continue;
auto endi = upper_bound(K, K + M, st[i].second) - K;
for(int j = starti; j < endi; j++){
if(cnt[j] < K[j]){
cnt[j]++;
break;
}
}
}
bool ok = 1;
for(int i = 0; i < M; i++){
if(cnt[i] != K[i]) ok = 0;
}
return ok;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 0; i < st.size(); i++){
| ~~^~~~~~~~~~~
teams.cpp:28:21: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
28 | for(int j = starti; j < endi; j++){
| ^~~~~~
# | 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... |