Submission #1279834

#TimeUsernameProblemLanguageResultExecution timeMemory
1279834proplayer팀들 (IOI15_teams)C++20
0 / 100
4094 ms12296 KiB
#include "teams.h"

#include<bits/stdc++.h>
using namespace std;
const int maxN = 5e5 + 5;
using ll = long long;


int a[maxN], b[maxN], n, m, k[maxN], id[maxN];
priority_queue<int> q;
bool cmp(int x, int y)
{
    return a[x] < a[y];
}
void init(int N, int A[], int B[])
{
    n = N;
    for (int i = 1; i <= n; ++i) a[i] = A[i - 1];
    for (int i = 1; i <= n; ++i) b[i] = B[i - 1];
    for (int i = 1; i <= n; ++i) id[i] = i;
    sort(id + 1, id + n + 1, cmp);
}

int can(int M, int K[])
{
    m = M;
    for (int i = 1; i <= m; ++i) k[i] = K[i - 1];
    sort(k + 1, k + m + 1);
    while (!q.empty()) q.pop();
    int j = 1;
    for (int i = 1; i <= m; ++i)
    {
        while (j <= n && a[id[j]] <= k[i])
        {
            q.push(b[id[j]]);
            ++j;
        }
        while (!q.empty() && q.top() < k[i]) q.pop();
        int cnt = k[i];
        while (cnt > 0)
        {
            if (q.empty()) return 0;
            q.pop();
            --cnt;
        }
    }
    return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...