You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.1 KiB
63 lines
1.1 KiB
|
|
#include <string>
|
|
#include <vector>
|
|
#include <optional>
|
|
#include <memory>
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <cstdint>
|
|
|
|
#include <input.h>
|
|
|
|
class [[gnu::visibility("hidden")]] Elf {
|
|
std::vector<size_t> _lines;
|
|
public:
|
|
Elf() = default;
|
|
Elf(Elf const&) = default;
|
|
Elf(Elf&&) = default;
|
|
Elf& operator=(Elf&&) = default;
|
|
Elf& operator=(Elf const&) = default;
|
|
~Elf() = default;
|
|
|
|
using ptr_t = decltype(INPUT)*;
|
|
|
|
template<size_t N>
|
|
static std::unique_ptr<Elf> read_from_input(const ptr_t (&input)[N])
|
|
{
|
|
Elf elf;
|
|
size_t n=0;
|
|
for(;n = **input;(*input)++) elf._lines.push_back(n);
|
|
if(n)
|
|
return std::make_unique<Elf>(std::move(elf));
|
|
else
|
|
return nullptr;
|
|
}
|
|
|
|
size_t sum() const noexcept
|
|
{
|
|
size_t s =0;
|
|
for(size_t sz : _lines) s+=sz;
|
|
return s;
|
|
}
|
|
};
|
|
|
|
static std::unique_ptr<Elf> read_elf()
|
|
{
|
|
constinit static const auto input = INPUT;
|
|
return Elf::read_from_input(&input);
|
|
}
|
|
|
|
int main() {
|
|
size_t max;
|
|
std::unique_ptr<Elf> e;
|
|
while(e = read_elf()) {
|
|
auto sum = e->sum();
|
|
if(sum>max) max = sum;
|
|
}
|
|
printf("%lu\n", max);
|
|
|
|
return 0;
|
|
}
|