Submission #210605

# Submission time Handle Problem Language Result Execution time Memory
210605 2020-03-17T20:29:48 Z Blagojce Watching (JOI13_watching) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
ll const inf = 1e9;
ll const mod = 1e9 + 7;
ld const eps = 1e-13;

ll n, p, q;
ll a[2000];

bool ok(ll w){
        ll dp[n + 1][q + 1];
        dp[0][0] = 0;
        fr(i, 1, n + 1){
                ll jlong;
                ll jshort;
                for(int j = i; j >= 1; j --){
                        if(a[i - 1] - a[j - 1] + 1 <= w) jshort = j;
                        if(a[i - 1] - a[j - 1] + 1 <= 2 * w) jlong = j;
                }
                fr(Q, 0, q + 1){
                        dp[i][Q] = inf;
                        if(Q > 0){
                                int bef = 0;
                                if(jlong > 0) bef = dp[jlong - 1][Q - 1];
                                dp[i][Q] = bef;
                        }
                        ll bef = 0;
                        if(jshort > 0) bef = dp[jshort - 1][Q];
                        dp[i][Q] = min(dp[i][Q], bef + 1);
                }
        }
        int BEST = inf;
        fr(i, 0, q + 1){
                BEST = min(BEST, dp[n][i]);
        }
        return BEST <= p;
}


void solve(){
        cin >> n >> p >> q;
        q = min(n, q);
        sort(a, a + n);
        fr(i, 0, n){
                cin >> a[i];
        }
        ll ans = 0;
        ll mx = 1e9;
        for(ll b = mx / 2; b >= 1; b /= 2){
                while(b + ans <= mx && !ok(b + ans)) ans += b;
        }
        cout << ans + 1 <<endl;

}
int main()
{
        solve();
        return 0;
}

Compilation message

watching.cpp: In function 'bool ok(ll)':
watching.cpp:44:42: error: no matching function for call to 'min(int&, ll&)'
                 BEST = min(BEST, dp[n][i]);
                                          ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
watching.cpp:44:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
                 BEST = min(BEST, dp[n][i]);
                                          ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
watching.cpp:44:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
                 BEST = min(BEST, dp[n][i]);
                                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
watching.cpp:44:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
                 BEST = min(BEST, dp[n][i]);
                                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
watching.cpp:44:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
                 BEST = min(BEST, dp[n][i]);
                                          ^