Submission details
Task:Apartments
Sender:aalto26bh_045
Submission time:2026-09-04 16:17:14 +0300
Language:C++ (C++23)
Status:COMPILE ERROR

Compiler report

In file included from input/code.cpp:2:
/usr/include/c++/13/format: In instantiation of 'class std::__format::_Checking_scanner<char, std::vector<int, std::allocator<int> > >':
/usr/include/c++/13/format:3750:4:   required from 'consteval std::basic_format_string<_CharT, _Args>::basic_format_string(const _Tp&) [with _Tp = char [3]; _CharT = char; _Args = {std::vector<int, std::allocator<int> >&}]'
input/code.cpp:19:29:   required from here
/usr/include/c++/13/format:3672:10: error: static assertion failed: std::formatter must be specialized for each type being formatted
 3672 |         (is_default_constructible_v<formatter<_Args, _CharT>> && ...),
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/format:3672:10: note: 'std::is_default_constructible_v<std::formatter<std::vector<int>, char> >' evaluates to false
/usr/include/c++/13/format: In instantiation of 'constexpr void std::__format::_Checking_scanner<_CharT, _Args>::_M_parse_format_spec(std:...

Code

#include <iostream>
#include <format>
#include <vector>
#include <algorithm>

int main(int argc, char **argv) {
    int n, m, k;
    std::cin >> n >> m >> k;

    std::vector<int> a(n);
    std::vector<int> b(m);

    for (int &x : a) std::cin >> x;
    for (int &x : b) std::cin >> x;

    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    std::cout << std::format("{}", a) << std::endl;
    std::cout << std::format("{}", b) << std::endl;

    int ai = 0;
    int bi = 0;
    int c = 0;

    while (ai < a.size() && bi < b.size()) {
        if (a.at(ai) > b.at(bi) + k) {
            bi += k;
        } else if (b.at(bi) > a.at(ai) + k) {
            ai += k;
        } else {
            c += 1;
            ai++;
            bi++;
        }
    }

    std::cout << c << std::endl;

    return 0;
}