이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// pragmas
#ifndef DEBUG
#endif
#include <bits/stdc++.h>
#include "teams.h"
// #define int long long
using ll = long long;
using namespace std;
int N;
vector<int> A;
vector<int> B;
vector<array<int, 2>> students_b;
set<array<int, 2>> students_a;
int cnt = 0;
void init(int _N, int _A[], int _B[]) {
cnt = 0;
N = _N;
A.assign(N, -1);
for (int i=0; i<N; i++) {
A[i] = _A[i];
}
B.assign(N, -1);
for (int i=0; i<N; i++) {
B[i] = _B[i];
}
students_b.clear();
for (int i=0; i<N; i++) {
students_b.push_back({B[i], i});
}
sort(students_b.begin(), students_b.end());
students_a.clear();
for (int i=0; i<N; i++) {
students_a.insert({A[i], i});
}
}
int can(int M, int _K[]) {
cnt++;
students_a.clear();
for (int i=0; i<N; i++) {
students_a.insert({A[i], i});
}
vector<int> K;
for (int i=0; i<M; i++) {
K.push_back(_K[i]);
}
sort(K.begin(), K.end());
// if (K[0] == 33) {
// // cerr << j << "-\n";
// for (auto &[x1, x2] : students_a) {
// cerr << x1 << " " << x2 << "\n";
// }
// }
int j = 0;
for (int i=0; i<M; i++) {
while (j<N && students_b[j][0]<K[i]) {
int idx = students_b[j][1];
if (students_a.count({A[idx], idx}))
students_a.erase({A[idx], idx});
j++;
}
for (int l=0; l<K[i]; l++) {
if (students_a.empty()) return 0;
int idx = (*students_a.begin())[1];
// if (! (A[idx] <= K[i] && B[idx] >= K[i]) ) {
// // for (auto &x : K) {
// // cerr << x << " ";
// // }
// // cerr << "--" << cnt << "\n";
// cerr << A[idx] << " " << idx << "\n";
// cerr << K[i] << "\n";
// assert(A[idx] <= K[i] && B[idx] >= K[i]);
// }
// cerr << i << " " << K[i] << "\n";
// if (K[i] == 33) {
// for (auto &[x1, x2] : students_a) {
// cerr << x1 << " " << x2 << "\n";
// }
// }
if (A[idx] > K[i]) return 0;
students_a.erase(students_a.begin());
}
}
return 1;
}
# | 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... |