Submission #1190114

#TimeUsernameProblemLanguageResultExecution timeMemory
1190114raspy로봇 (IOI13_robots)C++20
0 / 100
0 ms328 KiB
#include "robots.h"
#include <bits/stdc++.h>

using namespace std;

// w -> teze igrac, s - > velikosti igrac
// x -> omejitve dviga teze, y -> omejitve dviga velikosti

int putaway(int a, int b, int n, int X[], int Y[], int W[], int S[])
{
    vector<int> w, s, x, y;
    for (int i = 0; i < n; i++)
    {
        w.push_back(W[i]);
        s.push_back(S[i]);
    }
    for (int i = 0; i < a; i++)
        x.push_back(X[i]);
    for (int i = 0; i < b; i++)
        y.push_back(Y[i]);
    sort(y.begin(), y.end());
    sort(x.begin(), x.end());
    vector<pair<int, int>> igrace;
    for (int i = 0; i < n; i++)
        igrace.push_back(make_pair(w[i], s[i]));
    sort(igrace.begin(), igrace.end());
    auto mozno = [&igrace, &x, &y](int tr) -> bool
    {
        int j = 0;
        multiset<int> st;
        for (int v : x)
        {
            while (j < igrace.size() && igrace[j].first <= v)
            {
                st.insert(igrace[j].second);
                j++;
            }
            for (int i = 0; i < tr && st.size(); i++)
                st.erase(st.find(*st.rbegin()));
        }
        while (j < (int)igrace.size())
        {
            st.insert(igrace[j].second);
            j++;
        }
        for (int v : y)
        {
            for (int i = 0; i < tr && st.size(); i++)
                if (*st.begin() <= v)
                    st.erase(st.begin());
        }
        return st.empty();
    };
    if (!mozno(n+1))
        return -1;
    int l = -1, d = n;
    while (l+1 < d)
    {
        int mid = (l+d)/2;
        if (mozno(mid))
            d = mid;
        else
            l = mid;
    }
    return d;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...