Submission #1010916

#TimeUsernameProblemLanguageResultExecution timeMemory
1010916erraySki 2 (JOI24_ski2)C++17
Compilation error
0 ms0 KiB
// author: erray
#include <bits/stdc++.h>

#ifdef DEBUG
  #include "debug.h"
#else
  #define debug(...) void(37)
#endif

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> H(N), C(N);
  for (int i = 0; i < N; ++i) {
    cin >> H[i] >> C[i];
  }
  constexpr int64_t inf = int64_t(1e16);
  vector<int64_t> best(N, inf);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (H[j] >= H[i]) {
        best[i] = min(best[i], C[j] + 1LL * (H[j] - H[i] + 1) * K);
      } else {
        best[i] = min(best[i], 0LL + C[j]);
      }
    }
  }
  debug(best);
  map<int, vector<int>> hs;
  for (int i = 0; i < N; ++i) {
    hs[H[i]].push_back(i);
  }
  hs[int(2e9)] = {};
  int last = -1;
  int64_t ans = 0;
  priority_queue<int64_t> pq;
  for (auto[pos, v] : hs) {
    debug(pos, v, ans, pq);
    while (last < pos && (!pq.empty() && pq.top() >= (1LL * last * K))) {
      ans += 1LL * last * K - pq.top();
      pq.pop();  
      ++last;
    }
    sort(v.begin(), v.end(), [&](int x, int y) {
      return C[x] < C[y];
    });
    for (int i = 1; i < int(v.size()); ++i) {
      int ind = v[i];
      ans += best[ind];
      pq.push(1LL * pos * K + best[ind]);
    }
    last = pos + 1;
  } 
  cout << ans << '\n';
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:26:66: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)'
   26 |         best[i] = min(best[i], C[j] + 1LL * (H[j] - H[i] + 1) * K);
      |                                                                  ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:26:66: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   26 |         best[i] = min(best[i], C[j] + 1LL * (H[j] - H[i] + 1) * K);
      |                                                                  ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:26:66: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   26 |         best[i] = min(best[i], C[j] + 1LL * (H[j] - H[i] + 1) * K);
      |                                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:26:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   26 |         best[i] = min(best[i], C[j] + 1LL * (H[j] - H[i] + 1) * K);
      |                                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:26:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   26 |         best[i] = min(best[i], C[j] + 1LL * (H[j] - H[i] + 1) * K);
      |                                                                  ^
Main.cpp:28:42: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)'
   28 |         best[i] = min(best[i], 0LL + C[j]);
      |                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:28:42: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   28 |         best[i] = min(best[i], 0LL + C[j]);
      |                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:28:42: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   28 |         best[i] = min(best[i], 0LL + C[j]);
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:28:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   28 |         best[i] = min(best[i], 0LL + C[j]);
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:28:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   28 |         best[i] = min(best[i], 0LL + C[j]);
      |                                          ^