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 "teams.h"
#include <vector>
#include <cassert>
#include <algorithm>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define index(x, y) (int)(lower_bound(all(x), y)-x.begin())
int N;
int T[500001];
int Rlt[500001];
int Lgt[500001];
int count(int l, int r) {
assert(l <= r);
return N-(l>0?Rlt[l-1]:0)-(r+1<=N?Lgt[r+1]:0);
}
void init(int NN, int A[], int B[]) {
N = NN;
rep(i, N) {
T[A[i]]++;
if (B[i]+1<=N) T[B[i]+1]--;
Rlt[B[i]]++;
Lgt[A[i]]++;
}
rep(i, N) T[i+1] += T[i];
rep(i, N) Rlt[i+1] += Rlt[i];
for (int i=N; i>0; i--) Lgt[i-1] += Lgt[i];
}
int can(int M, int K[]) {
int sum = 0;
rep(i, M) sum += K[i];
if (sum > N) return 0;
sort(K, K+M);
rep(l, M) {
int sum = 0;
for (int r=l; r<M; r++) {
sum += K[r];
if (sum-count(K[l], K[r]) > 0) return 0;
}
}
return 1;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:40:9: warning: declaration of 'sum' shadows a previous local [-Wshadow]
int sum = 0;
^~~
teams.cpp:35:7: note: shadowed declaration is here
int sum = 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... |