Submission #1197011

#TimeUsernameProblemLanguageResultExecution timeMemory
1197011mychecksedadSki 2 (JOI24_ski2)C++20
Compilation error
0 ms0 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 300+5, M = 1e5+10, K = 52, MX = 30; const ll INF = 1e14; int n; ll k, p[605], dp[605][N][N][2], mn[605]; array<ll, 2> a[N]; void solve(){ cin >> n >> k; int m; for(int i = 1; i <= n; ++i){ cin >> a[i][0] >> a[i][1]; ++a[i][0]; m = max(m, a[i][0] + n + 1); } ll ans = INF; for(int i = 0; i <= m; ++i) p[i] = 0, mn[i] = INF; for(int i = 1; i <= n; ++i){ p[a[i][0]]++; mn[a[i][0]] = min(mn[a[i][0]], a[i][1]); } for(int i = 1; i <= m; ++i) p[i] += p[i - 1], mn[i] = min(mn[i], mn[i - 1]); for(int h = 0; h <= m; ++h){ for(int i = 0; i <= p[h]; ++i){ for(int l = 0; l <= p[h]; ++l) dp[h][i][l][0] = dp[h][i][l][1] = INF; } } sort(a+1, a+1+n); dp[0][0][0][0] = 0; for(int h = 1; h <= a[n][0] + n; ++h){ // for(int j = 0; j <= p[h - 1]; ++j){ // int sz = j + p[h] - p[h - 1]; // for(int mx = sz; mx <= n; ++mx){ // dp[h][0][mx] = min(dp[h][0][mx], dp[h - 1][j][mx]); // } // } for(int j = 0; j <= p[h - 1]; ++j){ for(int i = 0; i <= p[h] - p[h - 1] + j; ++i){ int sz = p[h] - p[h - 1] + j - i; for(int mx = 1; mx <= p[h]; ++mx){ dp[h][i][max(mx, sz)][1] = min(dp[h][i][max(mx, sz)][1], dp[h - 1][j][mx][1] + max(0ll, (sz - mx) * mn[h - 1]) + i * k); } } } if(p[h] > p[h - 1]){ dp[h][p[h] - 1][1][1] = min(dp[h][p[h] - 1][1][1], dp[h - 1][p[h - 1]][0][0] + (p[h] - 1) * k); } dp[h][p[h]][0][0] = min(dp[h][p[h]][0][0], dp[h - 1][p[h - 1]][0][0] + p[h] * k); } for(int h = a[n][0]; h <= a[n][0] + n; ++h){ for(int mx = 1; mx <= n; ++mx) ans = min(ans, dp[h][0][mx][1]); } cout << ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); en; } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:26:12: error: no matching function for call to 'max(int&, std::array<long long int, 2>::value_type)'
   26 |     m = max(m, a[i][0] + n + 1);
      |         ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:2:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:26:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<long long int, 2>::value_type' {aka 'long long int'})
   26 |     m = max(m, a[i][0] + n + 1);
      |         ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:2:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:26:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<long long int, 2>::value_type' {aka 'long long int'})
   26 |     m = max(m, a[i][0] + n + 1);
      |         ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
Main.cpp:26:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |     m = max(m, a[i][0] + n + 1);
      |         ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
Main.cpp:26:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |     m = max(m, a[i][0] + n + 1);
      |         ~~~^~~~~~~~~~~~~~~~~~~~