이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "teams.h"
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef array<int, 2> ii;
// #define endl '\n'
int n;
vi endbefore, beginafter; // both inclusive: before -> <=, after -> >=
void init(int N, int A[], int B[]) {
n = N;
endbefore.resize(n); beginafter.resize(n);
for_(i, 0, n) {
endbefore[B[i]-1]++; beginafter[A[i]-1]++;
}
for_(i, 1, n) endbefore[i] += endbefore[i-1];
for (int i = n-2; i >= 0; i--) beginafter[i] += beginafter[i+1];
}
int can(int M, int K[]) {
// return 0;
for_(i, 0, M) K[i] -= 1;
sort(K, K+M);
int mx = 0;
vi psum(M);
for_(i, 0, M) psum[i] += K[i]+1;
for_(i, 1, M) psum[i] += psum[i-1];
// cout << "yoyo!" << endl;
vi sufmx(M);
for (int i = M-1; i >= 0; i--) {
sufmx[i] = psum[i] + (K[i] < n-1 ? beginafter[K[i]+1] : 0);
if (i < M-1) sufmx[i] = max(sufmx[i], sufmx[i+1]);
}
// if (K[M-1]+1 < n) {
int ba = K[M-1]+1 < n ? beginafter[K[M-1]+1] : 0;
int eb = K[M-1]-1 >= 0 ? endbefore[K[M-1]-1] : 0;
// mx = K[M-1]+1 + ba + eb;
// }
for_(i, 0, M-1) {
int val = (K[i] >= 1 ? endbefore[K[i]-1] : 0) - (i > 0 ? psum[i-1] : 0) + sufmx[i];
mx = max(mx, val);
}
return mx <= n;
}
// int main() {
// #ifdef mlocal
// freopen("teams.in", "r", stdin);
// #endif
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// int t; cin >> t;
// cout << "got " << t << endl;
// while (t--) {
// }
// }
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In function 'int can(int, int*)':
teams.cpp:42:7: warning: unused variable 'ba' [-Wunused-variable]
42 | int ba = K[M-1]+1 < n ? beginafter[K[M-1]+1] : 0;
| ^~
teams.cpp:43:7: warning: unused variable 'eb' [-Wunused-variable]
43 | int eb = K[M-1]-1 >= 0 ? endbefore[K[M-1]-1] : 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... |