Submission #1131361

#TimeUsernameProblemLanguageResultExecution timeMemory
1131361vladiliusWatching (JOI13_watching)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
const int inf = 1e9;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, p, q; cin>>n>>p>>q;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++){
        cin>>a[i];
    }
    sort(a.begin() + 1, a.end());
    vector<int> :: iterator it;
    
    int dp[n + 1][p + 1];
    for (int j = 0; j <= p; j++) dp[0][j] = 0;
    
    auto check = [&](int w){
        for (int i = 1; i <= n; i++){
            for (int j = 0; j <= p; j++){
                dp[i][j] = inf;
            }
        }
        for (int i = 1; i <= n; i++){
            it = lower_bound(a.begin() + 1, a.end(), a[i] - w + 1);
            int t1 = (int) (it - a.begin()) - 1;
            it = lower_bound(a.begin() + 1, a.end(), a[i] - 2 * w + 1);
            int t2 = (int) (it - a.begin()) - 1;
            for (int j = 0; j <= p; j++){
                if (j < p) dp[i][j + 1] = min(dp[i][j + 1], dp[t1][j]);
                dp[i][j] = min(dp[i][j], dp[t2][j] + 1);
            }
        }
        return dp[n][p] <= q;
    };
    
    int l = 1, r = inf;
    while (l + 1 < r){
        int m = (l + r) / 2;
        if (check(m)){
            r = m;
        }
        else {
            l = m + 1;
        }
    }
    if (check(l)) r = l;
    
    cout<<r<<"\n";
}

Compilation message (stderr)

watching.cpp: In lambda function:
watching.cpp:29:17: sorry, unimplemented: capture of variably-modified type 'int [(n + 1)][(p + 1)]' that is not an N3639 array of runtime bound
   29 |                 dp[i][j] = inf;
      |                 ^~
watching.cpp:29:17: note: because the array element type 'int [(p + 1)]' has variable size
watching.cpp:38:28: sorry, unimplemented: capture of variably-modified type 'int [(n + 1)][(p + 1)]' that is not an N3639 array of runtime bound
   38 |                 if (j < p) dp[i][j + 1] = min(dp[i][j + 1], dp[t1][j]);
      |                            ^~
watching.cpp:38:28: note: because the array element type 'int [(p + 1)]' has variable size
watching.cpp:38:47: sorry, unimplemented: capture of variably-modified type 'int [(n + 1)][(p + 1)]' that is not an N3639 array of runtime bound
   38 |                 if (j < p) dp[i][j + 1] = min(dp[i][j + 1], dp[t1][j]);
      |                                               ^~
watching.cpp:38:47: note: because the array element type 'int [(p + 1)]' has variable size
watching.cpp:38:61: sorry, unimplemented: capture of variably-modified type 'int [(n + 1)][(p + 1)]' that is not an N3639 array of runtime bound
   38 |                 if (j < p) dp[i][j + 1] = min(dp[i][j + 1], dp[t1][j]);
      |                                                             ^~
watching.cpp:38:61: note: because the array element type 'int [(p + 1)]' has variable size
watching.cpp:39:17: sorry, unimplemented: capture of variably-modified type 'int [(n + 1)][(p + 1)]' that is not an N3639 array of runtime bound
   39 |                 dp[i][j] = min(dp[i][j], dp[t2][j] + 1);
      |                 ^~
watching.cpp:39:17: note: because the array element type 'int [(p + 1)]' has variable size
watching.cpp:39:32: sorry, unimplemented: capture of variably-modified type 'int [(n + 1)][(p + 1)]' that is not an N3639 array of runtime bound
   39 |                 dp[i][j] = min(dp[i][j], dp[t2][j] + 1);
      |                                ^~
watching.cpp:39:32: note: because the array element type 'int [(p + 1)]' has variable size
watching.cpp:39:42: sorry, unimplemented: capture of variably-modified type 'int [(n + 1)][(p + 1)]' that is not an N3639 array of runtime bound
   39 |                 dp[i][j] = min(dp[i][j], dp[t2][j] + 1);
      |                                          ^~
watching.cpp:39:42: note: because the array element type 'int [(p + 1)]' has variable size
watching.cpp:42:16: sorry, unimplemented: capture of variably-modified type 'int [(n + 1)][(p + 1)]' that is not an N3639 array of runtime bound
   42 |         return dp[n][p] <= q;
      |                ^~
watching.cpp:42:16: note: because the array element type 'int [(p + 1)]' has variable size