Submission #407065

#TimeUsernameProblemLanguageResultExecution timeMemory
407065mat_vThe short shank; Redemption (BOI21_prison)C++14
0 / 100
1 ms332 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[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; } } if(nxt[i] == 0)nxt[i] = n+1; } fb(i,n,1){ ff(j,0,d){ if(j == 0){ dp[i][j] = ans[i][n]; continue; } dp[i][j] = dp[nxt[i]][j] + ans[i][nxt[i]-1]; dp[i][j] = min(ans[i][i] + dp[i + 1][j - 1], dp[i][j]); } } 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: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:59:5: note: in expansion of macro 'fb'
   59 |     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:60:9: note: in expansion of macro 'ff'
   60 |         ff(j,0,d){
      |         ^~
#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...