Submission #120425

#TimeUsernameProblemLanguageResultExecution timeMemory
120425someone_aaTeams (IOI15_teams)C++17
21 / 100
33 ms15020 KiB
#include <bits/stdc++.h>
#include "teams.h"
#define P pair<int,int>
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
const int maxn = 110;
int cnt[maxn][maxn], n;
int used[maxn];
vector<P>intervals;

bool compare(P a, P b) {
    if(a.second == b.second) return a.first > b.first;
    else return a.second < b.second;
}

void init(int N, int A[], int B[]) {
    n = N;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<n;j++) {
            if(i >= A[j] && i <= B[j]) {
                cnt[i][B[j]]++;
            }
        }
    }
}

int can(int M, int K[]) {
    memset(used,0,sizeof(used));
    sort(K, K + M);

    int marked = 0;
    for(int i=0;i<M;i++) {
        marked = 0;
        for(int j=1;j<=n;j++) {
            if(cnt[K[i]][j] <= used[j]) continue;
            int diff = cnt[K[i]][j] - used[j];
            diff = min(diff, K[i] - marked);
            used[j] += diff;
            marked += diff;

            if(marked == K[i]) break;
        }

        if(marked != K[i]) return false;
    }
    return true;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...