Submission #712060

#TimeUsernameProblemLanguageResultExecution timeMemory
712060sharaelongRobots (IOI13_robots)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#ifdef SHARAELONG
#include "../../cpp-header/debug.hpp"
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

struct FenwickTree {
    vector<int> tree;
    FenwickTree(int size) {
        tree.resize(size+1, 0);
    }

    int sum(int pos) {
        int ret = 0;
        for (int i=pos+1; i>0; i &= (i-1)) ret += tree[i];
        return ret;
    }

    void add(int pos, int val) {
        for (int i=pos+1; i<tree.size(); i+=(i & -i)) tree[i] += val;
    }
};

void solve() {
    int a, b, t;
    cin >> a >> b >> t;
    vector<int> A(a), B(b);
    for (int& x: A) cin >> x;
    for (int& x: B) cin >> x;
    A.push_back(0);
    B.push_back(0);
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    vector<pii> toys(t);
    for (int i=0; i<t; ++i) {
        int w, s;
        cin >> w >> s;
        w = upper_bound(A.begin(), A.end(), w) - A.begin() - 1;
        s = upper_bound(B.begin(), B.end(), s) - B.begin() - 1;
        toys[i] = {w,s};
    }
    sort(toys.begin(), toys.end(), [](const pii& p, const pii& q) {
        if (p.second == q.second) return p.first > q.first;
        return p.second > q.second;
    });
    if (toys[0] == make_pair(a, b)) {
        cout << -1;
        return;
    }

    int ans = 1;
    FenwickTree fen(a+1);
    for (auto[x, y]: toys) {
        fen.add(x, 1);
        ans = max(ans, (fen.sum(a) - fen.sum(x-1) - 1) / (a+b-x-y) + 1);
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();
}

Compilation message (stderr)

robots.cpp: In member function 'void FenwickTree::add(int, int)':
robots.cpp:22:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int i=pos+1; i<tree.size(); i+=(i & -i)) tree[i] += val;
      |                           ~^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccyWLPNd.o: in function `main':
robots.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJ59SNd.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccJ59SNd.o: in function `main':
grader.c:(.text.startup+0x1b1): undefined reference to `putaway'
collect2: error: ld returned 1 exit status