이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
constexpr int N = 500;
int koszt[N+9][N+9];
int dp[N+9][N+9];
int a[N+9];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
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 pop=1e9;
for (int y=x;y<=n;y++){
pop = min(a[y],pop+1);
if (pop<=t)val++;
koszt[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]+koszt[x][y-1]);
}
}
}
cout << dp[n+1][d+1] << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |