Submission #407040

#TimeUsernameProblemLanguageResultExecution timeMemory
407040mat_vThe short shank; Redemption (BOI21_prison)C++14
15 / 100
33 ms1740 KiB
#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[505][505]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> d >> t; ff(i,1,n){ cin >> niz[i]; } d = min(n,d); fb(i,n,1){ ff(j,0,d){ if(j == 0){ int mn = niz[i]-1; ff(k,i,n){ mn++; mn = min(mn, niz[k]); if(mn <= t)dp[i][j]++; } continue; } int mn = niz[i] - 1; int tr = 0; dp[i][j] = 1e9; ff(k,i,n){ mn++; mn = min(mn, niz[k]); if(mn <= t)tr++; dp[i][j] = min(dp[i][j], dp[k + 1][j - 1] + tr); } } } cout << dp[1][d] << "\n"; return 0; }

Compilation message (stderr)

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:34:5: note: in expansion of macro 'ff'
   34 |     ff(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:39:5: note: in expansion of macro 'fb'
   39 |     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:40:9: note: in expansion of macro 'ff'
   40 |         ff(j,0,d){
      |         ^~
prison.cpp:6:27: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
prison.cpp:43:17: note: in expansion of macro 'ff'
   43 |                 ff(k,i,n){
      |                 ^~
prison.cpp:6:27: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
prison.cpp:53:13: note: in expansion of macro 'ff'
   53 |             ff(k,i,n){
      |             ^~
#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...