Submission #598511

#TimeUsernameProblemLanguageResultExecution timeMemory
598511Jarif_RahmanRobots (IOI13_robots)C++17
39 / 100
3086 ms8688 KiB
#include "robots.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int putaway(int A, int B, int n, int X[], int Y[], int W[], int S[]){
    sort(X, X+A);
    sort(Y, Y+B);

    vector<int> bw(n), bs(n);

    for(int i = 0; i < n; i++) bw[i] = i, bs[i] = i;

    sort(bw.begin(), bw.end(), [&](int a, int b){
        return W[a] < W[b];
    });
    sort(bs.begin(), bs.end(), [&](int a, int b){
        return S[a] < S[b];
    });

    function<bool(vector<int>, int)>is_distributable_weak = [&](vector<int> toys, int m){
        if(toys.size() > ll(A)*m) return 0;
        sort(toys.begin(), toys.end(), [&](int a, int b){
            return W[a] < W[b];
        });
        int c = m, ls = A-1;
        while(!toys.empty()){
            int x = toys.back();
            toys.pop_back();
            if(W[x] >= X[ls]) return 0;
            c--;
            if(c == 0) c = m, ls--;
        }
        return 1;
    };
    function<bool(vector<int>, int)>is_distributable_small = [&](vector<int> toys, int m){
        if(toys.size() > ll(B)*m) return 0;
        sort(toys.begin(), toys.end(), [&](int a, int b){
            return S[a] < S[b];
        });
        int c = m, ls = B-1;
        while(!toys.empty()){
            int x = toys.back();
            toys.pop_back();
            if(S[x] >= Y[ls]) return 0;
            c--;
            if(c == 0) c = m, ls--;
        }
        return 1;
    };

    for(int I = 1; I <= n; I++){
        vector<int> cur;
        vector<bool> marked(n, 0);

        for(int i = n-1; i >= 0; i--){
            cur.pb(bs[i]);
            if(is_distributable_weak(cur, I)) marked[bs[i]] = 1;
            else cur.pop_back();
        }

        vector<int> sth;
        for(int i = 0; i < n; i++) if(!marked[i]) sth.pb(i);

        if(is_distributable_small(sth, I)) return I;
    }

    return -1;
}

Compilation message (stderr)

robots.cpp: In lambda function:
robots.cpp:26:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   26 |         if(toys.size() > ll(A)*m) return 0;
      |            ~~~~~~~~~~~~^~~~~~~~~
robots.cpp: In lambda function:
robots.cpp:41:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   41 |         if(toys.size() > ll(B)*m) 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...
#Verdict Execution timeMemoryGrader output
Fetching results...