제출 #94786

#제출 시각아이디문제언어결과실행 시간메모리
94786someone_aa팀들 (IOI15_teams)C++17
0 / 100
4043 ms315520 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;
int n;
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=0;i<N;i++) {
        intervals.pb(mp(A[i], B[i]));
    }
    sort(intervals.begin(), intervals.end(), compare);
}

int OK[500100];

int can(int M, int K[]) {
    sort(K, K+M);
    ll sum = 0LL;
    for(int i=0;i<M;i++) {
        OK[i] = K[i];
        sum += 1LL * K[i];
    }
    if(sum > n) return 0;

    for(auto i:intervals) {
        cout<<i.first<<" "<<i.second<<"\n";
    }

    int pi = 0, pk = 0;
    int taken = 0;
    while(pi < n && pk < M) {
        if(OK[pk] >= intervals[pi].first && OK[pk] <= intervals[pi].second) {
            K[pk]--;
            taken++;
        }
        pi++;
        if(K[pk] == 0) pk++;
    }
    return (sum == taken);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...