Submission #786726

#TimeUsernameProblemLanguageResultExecution timeMemory
786726vnm06Teams (IOI15_teams)C++14
34 / 100
4077 ms10060 KiB
#include "teams.h"
#include<bits/stdc++.h>
using namespace std;

struct uchenik
{
    int le, ri;
    uchenik() {}
    uchenik(int a, int b)
    {
        le=a;
        ri=b;
    }
};

bool operator<(uchenik a, uchenik b)
{
    if(a.le==b.le) return a.ri<b.ri;
    return a.le<b.le;
}

int n;
uchenik t[100005];

void init(int N, int A[], int B[])
{
    n=N;
    for(int i=0; i<n; i++) t[i].le=A[i], t[i].ri=B[i];
    sort(t, t+n);
}

multiset<int> st;

int can(int M, int K[])
{
    st.clear();
    int id=0;
    sort(K, K+M);
    for(int i=0; i<M; i++)
    {
        while(id<n && t[id].le<=K[i])
        {
            st.insert(t[id].ri);
            id++;
        }
        while(!st.empty() && (*st.begin())<K[i]) st.erase(st.begin());
        if(st.size()<K[i]) return 0;
        for(int j=0; j<K[i]; j++) st.erase(st.begin());
    }
	return 1;
}

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:47:21: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         if(st.size()<K[i]) return 0;
      |            ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...