제출 #153819

#제출 시각아이디문제언어결과실행 시간메모리
153819Ruxandra985로봇 (IOI13_robots)C++14
14 / 100
767 ms23352 KiB
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include "robots.h"
#include <queue>
using namespace std;

int ok (int gmax ,int a , int b , int t , int y[],int s[],vector <int> v[50010] ){
    int i,j;
    /// pana acum am log 10^6
    priority_queue <int> h,h2;
    for (i=0;i<=a;i++){
        for (j=0;j<v[i].size();j++)
            h.push(s[i]);
        if (i!=a){
            for (j=1;j<=gmax && !h.empty();j++)
                h.pop(); /// cele mai mari gmax sizeuri le pun aici
        }
    }
    /// in h au ramas cele pe care trebuie tu sa le pui la robotii mici
    while (!h.empty()){
        h2.push(-h.top());
        h.pop();
    }
    for (i=0;i<b;i++){
        for (j=1;j<=gmax && !h2.empty() && -h2.top()<=y[i];j++){
            h2.pop();
        }
    }
    return h2.empty();

}
int putaway (int a , int b , int t , int x[],int y[],int w[],int s[]){
    int maxw,maxs,i,k,st,dr,mid;
    vector <int> v[50010];
    /// cazul cand nu se poate
    maxw = maxs = 0;
    for (i=0;i<a;i++){
        x[i]--;
        maxw = max ( maxw , x[i] );
    }
    for (i=0;i<b;i++){
        y[i]--;
        maxs = max ( maxs , y[i] );
    }
    for (i=0;i<t;i++){
        if (w[i] > maxw && s[i] > maxs) /// nu se poate
            return -1;
    }
    /// stim ca se poate
    /// initial , le pun pe toate ca fiind pentru weak + un elem fictiv
    x[a] = 2000000000;
    sort (x , x + a);
    sort (y , y + a);
    k = 0;
    for (i=0;i<t;i++){ /// cel mai mic x in care pot sa o pun
        st = 0;
        dr = a;
        while (st<=dr){
            mid = (st + dr)/2;
            if (x[mid] >= w[i])
                dr = mid - 1;
            else st = mid + 1;
        }
        v[st].push_back(i); /// pe st poti sa o pui
        if (v[st].size() > k)
            k = v[st].size();
    }
    st = 1;
    dr = k;
    while (st<=dr){
        mid = (st + dr)/2;
        if (ok(mid ,a,b,t,y,s , v))
            dr = mid - 1;
        else st = mid + 1;
    }
    return st;
}

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

robots.cpp: In function 'int ok(int, int, int, int, int*, int*, std::vector<int>*)':
robots.cpp:14:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j=0;j<v[i].size();j++)
                  ~^~~~~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:67:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (v[st].size() > k)
             ~~~~~~~~~~~~~^~~
#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...