이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 5e5+2, oo = 1e9;
#include "teams.h"
int pref[mxN] = {}, pref2[mxN];
void init(int N, int A[], int B[]) {
for(int i=0;i<N;++i) {
pref[A[i]]++;
pref2[B[i]+1]++;
}
partial_sum(pref,pref+mxN,pref);
partial_sum(pref2,pref2+mxN,pref2);
}
int can(int M, int K[]) {
sort(K,K+M);
int from=0, opens=0, closes=0;
for(int i=0;i<M;++i) {
int at = K[i];
opens+=pref[at]-pref[from];
int tmp = min(closes,pref2[at]-pref2[from]);
closes-=tmp;
opens-=pref2[at]-pref2[from]-tmp;
if(opens<at) return false;
opens-=at;
closes+=at;
from = at;
}
return true;
}
# | 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... |