Submission #406057

#TimeUsernameProblemLanguageResultExecution timeMemory
406057maomao90The short shank; Redemption (BOI21_prison)C++17
15 / 100
2078 ms46452 KiB
#include <bits/stdc++.h> using namespace std; #define mnto(x, y) x = min(x, (__typeof__(x)) y) #define mxto(x, y) x = max(x, (__typeof__(x)) y) #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; #define MT make_tuple typedef tuple<int, int, int> iii; #define ALL(_a) _a.begin(), _a.end() #define pb emplace_back typedef vector<int> vi; typedef vector<ii> vii; #define INF 1000000005 #define LINF 1000000000000000005 #define MOD 1000000007 #define MAXN 4005 int n, d, t; int ti[MAXN]; int cost[MAXN][MAXN]; ll dp[MAXN][MAXN]; int main() { scanf("%d%d%d", &n, &d, &t); REP (i, 1, n + 1) { scanf("%d", &ti[i]); } REP (i, 1, n + 1) { ll r = -1; int cur = 0; REP (j, i, n + 1) { if (t >= ti[j]) mxto(r, t - ti[j] + j); if (r >= j) cur++; cost[i][j] = cur; } } REP (i, 1, n + 1) { dp[0][i] = cost[1][i]; } REP (i, 1, d + 1) { REP (j, 1, n + 1) { dp[i][j] = LINF; REP (k, 1, j) { mnto(dp[i][j], dp[i - 1][k] + cost[k + 1][j]); } } } printf("%lld\n", dp[d][n]); return 0; }

Compilation message (stderr)

prison.cpp: In function 'int main()':
prison.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d%d%d", &n, &d, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
prison.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d", &ti[i]);
      |   ~~~~~^~~~~~~~~~~~~~
#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...