Submission #417854

#TimeUsernameProblemLanguageResultExecution timeMemory
417854Kevin_Zhang_TWThe short shank; Redemption (BOI21_prison)C++17
15 / 100
2076 ms11012 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define pb emplace_back #define AI(i) begin(i), end(i) template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); } template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); } #ifdef KEV #define DE(args...) kout("[ " + string(#args) + " ] = ", args) void kout() { cerr << endl; } template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); } template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; } #else #define DE(...) 0 #define debug(...) 0 #endif const int MAX_N = 4005, inf = 1e9; int dp[MAX_N][MAX_N]; int n, D, T; // i can activate [i, nxt[i]) int s[MAX_N], nxt[MAX_N]; void solve_dp() { vector<int> ok(n + 10); for (int i = n;i >= 1;--i) { for (int j = i;j < nxt[i];++j) ok[j] = true; dp[i][1] = accumulate(begin(ok)+i, end(ok), 0); for (int j = 2;j <= n;++j) { dp[i][j] = inf; int sum = 0; for (int k = i+1;k <= n;++k) { sum += ok[k-1]; chmin(dp[i][j], sum + dp[k][j-1]); } } } for (int j = 1;j <= n;++j) DE(dp[1][j]); for (int j = 2;j < n;++j) { assert( dp[1][j] - dp[1][j-1] <= dp[1][j+1] - dp[1][j] ); } } int32_t main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n >> D >> T; ++D; // Just to be faster assert(n < MAX_N); for (int i = 1;i <= n;++i) { cin >> s[i]; nxt[i] = min(n+1, max(i, i + T - s[i] + 1)); } solve_dp(); cout << dp[1][D] << '\n'; }

Compilation message (stderr)

prison.cpp: In function 'void solve_dp()':
prison.cpp:14:17: warning: statement has no effect [-Wunused-value]
   14 | #define DE(...) 0
      |                 ^
prison.cpp:43:3: note: in expansion of macro 'DE'
   43 |   DE(dp[1][j]);
      |   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...