Submission #830880

#TimeUsernameProblemLanguageResultExecution timeMemory
830880drdilyorTeams (IOI15_teams)C++17
34 / 100
4056 ms10940 KiB
#include<bits/stdc++.h>
#include "teams.h"
using namespace std;
using ll = long long;

int n;
vector<pair<int,int>> arr;
void init(int n, int* a, int* b) {
    ::n = n;
    arr.resize(n);
    for( int i = 0; i < n; i++)
        arr[i] = {a[i], b[i]};
}

int can(int m, int* ts) {
    sort(ts, ts + m, greater());
    sort(arr.begin(), arr.end(), greater());
    vector<int> used(n);
    int team = 0;
    while (team < m) {
        int cnt = 0;
        for (int student = 0; student < n; student++) {
            if (used[student]) continue;
            auto [l,r] = arr[student];
            if (l <= ts[team] && ts[team] <= r) {
                used[student] = 1;
                cnt++;
            }
            if (cnt == ts[team]) break;
        }
        if (cnt == ts[team]) team++;
        else break;
    }
    return team == m;
}

Compilation message (stderr)

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:8:15: warning: declaration of 'n' shadows a global declaration [-Wshadow]
    8 | void init(int n, int* a, int* b) {
      |           ~~~~^
teams.cpp:6:5: note: shadowed declaration is here
    6 | int n;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...