답안 #760435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760435 2023-06-17T14:52:15 Z lalig777 Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 316 KB
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
    int dp[n+1][n+1];
    int v[n];
    for (int i=0; i<n; i++){
        cin>>v[i];
        if (dp[0][i]!=-1 and v[i]-dp[0][i]<=k) dp[0][i+1]=v[i];
        else dp[0][i+1]=-1;
    }if (dp[0][n]!=-1){
        cout<<0<<endl;
        return 0;
    }for (int i=1; i<=n; i++){
        for (int j=i; j<=n; j++){
            int a=-1, b=-1;
            if (dp[i-1][j-1]!=-1) a=dp[i-1][j-1]+k;
            if (dp[i][j-1]!=-1 and v[j-1]-dp[i][j-1]<=k) b=v[j-1];
            dp[i][j]=max(a, b);
        }if (dp[i][n]!=-1){
            cout<<i<<endl;
            return 0;
        }
    }return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -