Submission #494004

#TimeUsernameProblemLanguageResultExecution timeMemory
494004TeaTimeRobots (IOI13_robots)C++17
Compilation error
0 ms0 KiB
#include "robots.h"

typedef long long ll;

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
    ll mx = 1e6 + 100;
    int l = 0, r = mx;
    while (r - l > 1) {
        int mid = (l + r) / 2;

        vector<pair<int, int>> vec;
        vector<int> skip(T);
        for (int i = 0; i < T; i++) vec.push_back({ W[i], S[i] });

        map<int, int> st;
        vector<ll> svd;
        for (int i = 0; i < A; i++) svd.push_back(X[i]);
        reverse(svd.begin(), svd.end());

        for (int i = 0; i < B; i++) {
            st[Y[i]] += mid;
        }

        sort(vec.rbegin(), vec.rend());

        for (int i = 0; i < T; i++) {
            if (st.lower_bound(vec[i].second) != st.end()) {
                ll x = (*st.lower_bound(vec[i].second)).first;
                st[x]--;
                skip[i] = 1;
                if (st[x] == 0) st.erase(x);
            }
        }

        ll pt = 0, pt2 = 0;
        bool f = 1;
        for (int i = 0; i < T; i++) {
            if (skip[i]) continue;

            if (svd.size() > pt && svd[pt] >= vec[i].first) {
                pt2++;
                if (pt2 == mid) {
                    pt2 = 0;
                    pt++;
                }
            } else {
                f = 0;
                break;
            }
        }

        if (f) {
            r = mid;
        } else {
            l = mid;
        }
    }


    if (r == mx) {
        return -1;
    } else {
        return r;
    }
}

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:11:9: error: 'vector' was not declared in this scope
   11 |         vector<pair<int, int>> vec;
      |         ^~~~~~
robots.cpp:11:16: error: 'pair' was not declared in this scope
   11 |         vector<pair<int, int>> vec;
      |                ^~~~
robots.cpp:11:21: error: expected primary-expression before 'int'
   11 |         vector<pair<int, int>> vec;
      |                     ^~~
robots.cpp:12:16: error: expected primary-expression before 'int'
   12 |         vector<int> skip(T);
      |                ^~~
robots.cpp:13:37: error: 'vec' was not declared in this scope
   13 |         for (int i = 0; i < T; i++) vec.push_back({ W[i], S[i] });
      |                                     ^~~
robots.cpp:15:9: error: 'map' was not declared in this scope
   15 |         map<int, int> st;
      |         ^~~
robots.cpp:15:13: error: expected primary-expression before 'int'
   15 |         map<int, int> st;
      |             ^~~
robots.cpp:16:18: error: expected primary-expression before '>' token
   16 |         vector<ll> svd;
      |                  ^
robots.cpp:16:20: error: 'svd' was not declared in this scope; did you mean 'std'?
   16 |         vector<ll> svd;
      |                    ^~~
      |                    std
robots.cpp:18:9: error: 'reverse' was not declared in this scope
   18 |         reverse(svd.begin(), svd.end());
      |         ^~~~~~~
robots.cpp:21:13: error: 'st' was not declared in this scope; did you mean 'std'?
   21 |             st[Y[i]] += mid;
      |             ^~
      |             std
robots.cpp:24:14: error: 'vec' was not declared in this scope
   24 |         sort(vec.rbegin(), vec.rend());
      |              ^~~
robots.cpp:24:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |         sort(vec.rbegin(), vec.rend());
      |         ^~~~
      |         short
robots.cpp:27:17: error: 'st' was not declared in this scope; did you mean 'std'?
   27 |             if (st.lower_bound(vec[i].second) != st.end()) {
      |                 ^~
      |                 std
robots.cpp:30:17: error: 'skip' was not declared in this scope
   30 |                 skip[i] = 1;
      |                 ^~~~
robots.cpp:38:17: error: 'skip' was not declared in this scope
   38 |             if (skip[i]) continue;
      |                 ^~~~