Language: C++

#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

int main() {
  int N = 0;
  std::scanf("%d", &N);
  std::vector<int64_t> shops;
  shops.resize(N);

  for (int i = 0; i < N; i++) {
    int f1, f2, f3, f4, f5, f6, f7, f8, f9, f10;
    scanf("%d %d %d %d %d %d %d %d %d %d", &f1, &f2, &f3, &f4, &f5, &f6, &f7,
          &f8, &f9, &f10);
    shops[i] = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
  }

  bool opened = false;
  int second = -INT_MAX;
  int64_t result = 0;
  for (int i = 0; i < N; i++) {
    int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11;
    scanf("%d %d %d %d %d %d %d %d %d %d %d", &p1, &p2, &p3, &p4, &p5, &p6, &p7,
          &p8, &p9, &p10, &p11);
    using P = std::pair<uint32_t, int>;
    std::vector<P> p;
    p.resize(11);
    p[0] = std::make_pair(0, p1);
    p[1] = std::make_pair(1, p2);
    p[2] = std::make_pair(2, p3);
    p[3] = std::make_pair(3, p4);
    p[4] = std::make_pair(4, p5);
    p[5] = std::make_pair(5, p6);
    p[6] = std::make_pair(6, p7);
    p[7] = std::make_pair(7, p8);
    p[8] = std::make_pair(8, p9);
    p[9] = std::make_pair(9, p10);
    p[10] = std::make_pair(10, p11);
    std::sort(p.begin(), p.end(), [](const P& a, const P& b) {
                                    return a.second > b.second;
                                  });
    second = std::max(second, p[1]);
    for (const auto& e: p) {
      if (shops[i] >= e.first) {
        opened = e.first > 0;
        result += e.second;
        break;
      }
    }
  }

  if (!opened) {
    std::cout << second << std::endl;
  } else {
    std::cout << result << std::endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:25: error: 'uint32_t' was not declared in this scope
   27 |     using P = std::pair<uint32_t, int>;
      |                         ^~~~~~~~
a.cc:6:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    5 | #include <climits>
  +++ |+#include <cstdint>
    6 | 
a.cc:27:38: error: template argument 1 is invalid
   27 |     using P = std::pair<uint32_t, int>;
      |                                      ^
a.cc:28:17: error: 'P' was not declared in this scope
   28 |     std::vector<P> p;
      |                 ^
a.cc:28:18: error: template argument 1 is invalid
   28 |     std::vector<P> p;
      |                  ^
a.cc:28:18: error: template argument 2 is invalid
a.cc:29:7: error: request for member 'resize' in 'p', which is of non-class type 'int'
   29 |     p.resize(11);
      |       ^~~~~~
a.cc:30:6: error: invalid types 'int[int]' for array subscript
   30 |     p[0] = std::make_pair(0, p1);
      |      ^
a.cc:31:6: error: invalid types 'int[int]' for array subscript
   31 |     p[1] = std::make_pair(1, p2);
      |      ^
a.cc:32:6: error: invalid types 'int[int]' for array subscript
   32 |     p[2] = std::make_pair(2, p3);
      |      ^
a.cc:33:6: error: invalid types 'int[int]' for array subscript
   33 |     p[3] = std::make_pair(3, p4);
      |      ^
a.cc:34:6: error: invalid types 'int[int]' for array subscript
   34 |     p[4] = std::make_pair(4, p5);
      |      ^
a.cc:35:6: error: invalid types 'int[int]' for array subscript
   35 |     p[5] = std::make_pair(5, p6);
      |      ^
a.cc:36:6: error: invalid types 'int[int]' for array subscript
   36 |     p[6] = std::make_pair(6, p7);
      |      ^
a.cc:37:6: error: invalid types 'int[int]' for array subscript
   37 |     p[7] = std::make_pair(7, p8);
      |      ^
a.cc:38:6: error: invalid types 'int[int]' for array subscript
   38 |     p[8] = std::make_pair(8, p9);
      |      ^
a.cc:39:6: error: invalid types 'int[int]' for array subscript
   39 |     p[9] = std::make_pair(9, p10);
      |      ^
a.cc:40:6: error: invalid types 'int[int]' for array subscript
   40 |     p[10] = std::make_pair(10, p11);
      |      ^
a.cc:41:17: error: request for member 'begin' in 'p', which is of non-class type 'int'
   41 |     std::sort(p.begin(), p.end(), [](const P& a, const P& b) {
      |                 ^~~~~
a.cc:41:28: error: request for member 'end' in 'p', which is of non-class type 'int'
   41 |     std::sort(p.begin(), p.end(), [](const P& a, const P& b) {
      |                            ^~~
a.cc:41:44: error: 'P' does not name a type
   41 |     std::sort(p.begin(), p.end(), [](const P& a, const P& b) {
      |                                            ^
a.cc: In lambda function:
a.cc:43:37: error: expected '{' before ';' token
   43 |                                   });
      |                                     ^
a.cc: In function 'int main()':
a.cc:43:37: error: expected ')' before ';' token
   43 |                                   });
      |                                     ^
      |                                     )
a.cc:41:14: note: to match this '('
   41 |     std::sort(p.begin(), p.end(), [](const P& a, const P& b) {
      |              ^
a.cc:44:32: error: invalid types 'int[int]' for array subscript
   44 |     second = std::max(second, p[1]);
      |                                ^
a.cc:45:25: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   45 |     for (const auto& e: p) {
      |                         ^
      |                         std::begin
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:45:25: error: 'end' was not declared in this scope; did you mean 'std::end'?
   45 |     for (const auto& e: p) {
      |                         ^
      |                         std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~