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 "grader.cpp"
#include <bits/stdc++.h>
#define mk make_pair
#define sc second
#define fr first
#define pb push_back
using namespace std;
const int NN = (1e6 + 5);
const int inf = (1e9 + 7);
int n,m;
int a[NN],b[NN];
int k[NN];
int u[NN];
deque <pair<int,int> > v;
void init(int N, int A[], int B[]) {
n = N;
for (int i = 0; i < n; i ++) {
a[i] = A[i],b[i] = B[i];
}
}
int can(int M, int K[]) {
int m = M;
v.clear();
for (int i = 0; i < m; i ++)
k[i] = K[i];
sort (k,k + m);
for (int i = 0; i < n; i ++)
v.pb(mk(b[i],a[i]));
sort (v.begin(),v.end());
for (int i = 0; i < m; i ++) {
int cn = 0;
deque<pair<int,int> > dq;
dq.clear();
while (!v.empty()) {
if (v.front().fr >= k[i] && v.front().sc <= k[i])
cn ++,v.pop_front();
else {
if (v.front().fr <= k[i]) v.pop_front();
else {
dq.pb(v.front());
v.pop_front();
}
}
if (cn == k[i]) break;
}
if (cn != k[i]) return 0;
v.swap(dq);
for (auto to : dq)
v.pb(to);
}
return 1;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:32:11: warning: declaration of 'm' shadows a global declaration [-Wshadow]
int m = M;
^
teams.cpp:16:7: note: shadowed declaration is here
int n,m;
^
# | 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... |