Submission #407050

# Submission time Handle Problem Language Result Execution time Memory
407050 2021-05-18T12:13:02 Z mat_v The short shank; Redemption (BOI21_prison) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


int n,d,t;
int niz[100005];

int dp[4005][4005];
int ans[4005][4005];
int nxt[4005];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);

    cin >> n >> d >> t;
    ff(i,1,n){
        cin >> niz[i];
        niz[i] -= i;
    }
    d = min(n,d);
    ff(i,1,n){
        int mn = niz[i];
        ff(j,i,n){
            if(j > i)ans[i][j] += ans[i][j - 1];
            mn = min(mn, niz[j]);
            if(mn <= t-i)ans[i][j]++;
        }
    }
    ff(i,1,n){
        ff(j,i+1,n){
            if(niz[j] <= niz[i]){
                nxt[i] = j;
                break;
            }
        }
    }

    fb(i,n,1){
        ff(j,0,d){
            if(j == 0){
                dp[i][j] = ans[i][n];
                continue;
            }
            dp[i][j] = dp[i + 1][j] + ans[i][i];
            if(nxt[i] != 0){
                dp[i][j] = min(dp[i][j], dp[nxt[i]][j] + ans[i][nxt[i] - 1]);
            }
        }
    }
    cout << dp[1][d] << "\n";
    return 0;
}

Compilation message

prison.cpp: In function 'int main()':
prison.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
prison.cpp:36:5: note: in expansion of macro 'ff'
   36 |     ff(i,1,n){
      |     ^~
prison.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
prison.cpp:41:5: note: in expansion of macro 'ff'
   41 |     ff(i,1,n){
      |     ^~
prison.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
prison.cpp:43:9: note: in expansion of macro 'ff'
   43 |         ff(j,i,n){
      |         ^~
prison.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
prison.cpp:49:5: note: in expansion of macro 'ff'
   49 |     ff(i,1,n){
      |     ^~
prison.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
prison.cpp:50:9: note: in expansion of macro 'ff'
   50 |         ff(j,i+1,n){
      |         ^~
prison.cpp:7:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
      |                           ^
prison.cpp:58:5: note: in expansion of macro 'fb'
   58 |     fb(i,n,1){
      |     ^~
prison.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
prison.cpp:59:9: note: in expansion of macro 'ff'
   59 |         ff(j,0,d){
      |         ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -