Submission #268580

#TimeUsernameProblemLanguageResultExecution timeMemory
268580A02Teams (IOI15_teams)C++14
34 / 100
4067 ms16524 KiB
#include "teams.h"
#include <vector>
#include <set>
#include <algorithm>
#include <utility>
#include <queue>
#include <iostream>

using namespace std;

vector<pair<int, int> > intervals;

void init(int N, int A[], int B[]) {

    for (int i = 0; i < N; i++){
        intervals.push_back(make_pair(A[i], B[i]));
    }

    sort(intervals.begin(), intervals.end());
}

int can(int M, int K[]) {

    vector<long long> projects;

    for (int i = 0; i < M; i++){
        projects.push_back(K[i]);
    }

    sort(projects.begin(), projects.end());

    priority_queue<pair<int, int> > interval_queue;

    int c_student = 0;

    for (int i = 0; i < M; i++){
        int to_fill = projects[i];

        while (c_student < intervals.size() && intervals[c_student].first <= projects[i]){

            interval_queue.push(make_pair(-intervals[c_student].second, intervals[c_student].first));
            c_student++;

        }

        while (to_fill > 0 && !interval_queue.empty()){
            pair<int, int> f = interval_queue.top();
            //cout << f.first << ' ' << f.second << endl;
            if (-f.first >= projects[i]){
                to_fill--;
            }
            interval_queue.pop();
        }

        if (to_fill != 0){
            //cout << 0 << endl;
            return 0;
        }

    }
   // cout << 1 << endl;
	return 1;
}

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:37:33: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   37 |         int to_fill = projects[i];
      |                                 ^
teams.cpp:39:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         while (c_student < intervals.size() && intervals[c_student].first <= projects[i]){
      |                ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...