# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
540862 | GioChkhaidze | Teams (IOI15_teams) | C++14 | 4081 ms | 57200 KiB |
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 <bits/stdc++.h>
#include "teams.h"
#define ll long long
#define pb push_back
using namespace std;
const int Nn = 5e5 + 5;
ll n, a[Nn], b[Nn], f[Nn];
vector < ll > G[Nn];
multiset < ll > st;
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];
}
for (int i = 0; i < n; ++i) {
G[a[i]].pb(i);
}
}
int can(int M, int K[]) {
ll s = 0;
for (int i = 0; i < M; ++i) {
f[K[i]]++;
s += K[i];
}
st.clear();
bool ok = true;
if (s > n) ok = false;
else {
for (int i = 1; i <= n; ++i) {
for (int j = 0; j < G[i].size(); ++j) {
int id = G[i][j];
st.insert(b[id]);
}
if (f[i] * i > n) { ok = false; break; }
for (int j = 1; j <= f[i] * i; ++j) {
if (!st.size()) { ok = false; break; }
if ((*st.begin()) < i) { ok = false; break; }
st.erase(st.find(*st.begin()));
}
if(!ok) break;
}
}
for (int i = 0; i < M; ++i) {
f[K[i]] = 0;
}
return ok;
}
Compilation message (stderr)
# | 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... |