제출 #1035812

#제출 시각아이디문제언어결과실행 시간메모리
1035812andrei_iorgulescu로봇 (IOI13_robots)C++14
76 / 100
3069 ms46548 KiB
#include <bits/stdc++.h>
#include "robots.h"

using namespace std;

vector<int> x,y;
vector<pair<int,int>> robots;

bool cmp(pair<int,int> A, pair<int,int> B)
{
    return A.second < B.second;
}

bool pot(int k)
{
    vector<bool> luat(robots.size());
    set<pair<int,int>> s;///y si indexul
    int i1 = 0;
    for (int i = 0; i < x.size(); i++)
    {
        while (i1 < robots.size() and robots[i1].first < x[i])
        {
            s.insert({robots[i1].second,i1});
            i1++;
        }
        int ct = k;
        while (!s.empty() and ct > 0)
        {
            ct--;
            pair<int,int> idk = *s.rbegin();
            s.erase(idk);
            luat[idk.second] = true;
        }
    }
    s.clear();
    vector<pair<int,int>> r;
    for (int i = 0; i < robots.size(); i++)
        if (!luat[i])
            r.push_back(robots[i]);
    sort(r.begin(),r.end(),cmp);
    i1 = 0;
    int lt = 0;
    for (int i = 0; i < y.size(); i++)
    {
        while (i1 < r.size() and r[i1].second < y[i])
        {
            s.insert({r[i1].first,i1});
            i1++;
        }
        int ct = k;
        while (!s.empty() and ct > 0)
        {
            ct--;
            lt++;
            pair<int,int> idk = *s.rbegin();
            s.erase(idk);
        }
    }
    if (lt == r.size())
        return true;
    return false;
}

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
    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(x.begin(),x.end());
    sort(y.begin(),y.end());
    for (int i = 0; i < T; i++)
        robots.push_back({W[i],S[i]});
    sort(robots.begin(),robots.end());
    for (auto it : robots)
        if ((A == 0 or it.first >= x[A - 1]) and (B == 0 or it.second >= y[B - 1]))
            return -1;
    int st = 0,pas = 1 << 19;
    while (pas != 0)
    {
        if (!pot(st + pas))
            st += pas;
        pas /= 2;
    }
    return st + 1;
}

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp: In function 'bool pot(int)':
robots.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < x.size(); i++)
      |                     ~~^~~~~~~~~~
robots.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         while (i1 < robots.size() and robots[i1].first < x[i])
      |                ~~~^~~~~~~~~~~~~~~
robots.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < robots.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
robots.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i = 0; i < y.size(); i++)
      |                     ~~^~~~~~~~~~
robots.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         while (i1 < r.size() and r[i1].second < y[i])
      |                ~~~^~~~~~~~~~
robots.cpp:59:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     if (lt == r.size())
      |         ~~~^~~~~~~~~~~
#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...