Submission #1109691

#TimeUsernameProblemLanguageResultExecution timeMemory
1109691Malek1387The short shank; Redemption (BOI21_prison)C++17
15 / 100
18 ms2504 KiB
#include<bits/stdc++.h> #define tizoboz ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define ld long double #define pb push_back // #define int long long #define itn int #define ss set <int> #define prq priority_queue <int> #define endl '\n' const ll MOD = 1e9 + 7; #define md(x) (((x%MOD)+MOD)%MOD) #define vi vector <int> #define vl vector<ll> #define str string #define mp make_pair #define mata int32_t #define sz size #define lc id *2 #define rc lc +1 #define SZ(x) (int)x.size() #define mid (l+r)/2 #define cn cin #define ct cout #define sep " " #define F first #define X first #define S second #define Y second using namespace std; typedef pair <int , int> pii; const ll maxn = 5e2 + 9 ; const int Lg = 23; int a[maxn+9] , b[maxn+9][maxn+9] , dp[maxn+9][maxn+9]; void solve (){ int n,d,t; cin >> n >> d >> t; for (int x=1;x<=n;x++){ cin >> a[x]; } for (int x=1;x<=n;x++){ int val=0; int pp=1e9; for (int y=x;y<=n;y++){ pp = min(a[y],pp+1); if (pp<=t)val++; b[x][y]=val; } } for (int x=0;x<=n+1;x++){ for (int y=0;y<=d+1;y++)dp[x][y]=1e9; } dp[1][0]=0; for (int x=1;x<=n;x++){ for (int k=0;k<=d;k++){ for (int y=x+1;y<=n+1;y++){ dp[y][k+1]=min(dp[y][k+1],dp[x][k]+b[x][y-1]); } } } cout << dp[n+1][d+1] << endl; } mata main(){ tizoboz; int tt = 1; // cn >> tt; while (tt--){ solve(); } return 0; }
#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...