Submission #76855

# Submission time Handle Problem Language Result Execution time Memory
76855 2018-09-18T17:38:43 Z Vardanyan Stove (JOI18_stove) C++14
50 / 100
214 ms 83244 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 5007;
long long a[N];
long long dp[N][N];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 1;i<=n;i++){
            scanf("%lld",&a[i]);
            for(int j = 0;j<=k;j++) dp[i][j] = 100000000000000005;
    }
    for(int kk = 1;kk<=k;kk++){
        dp[1][kk] = 1;
        for(int i = 2;i<=n;i++){
            dp[i][kk] = min(dp[i][kk],dp[i-1][kk]+((a[i]+1)-(a[i-1]+1)));
            dp[i][kk+1] = min(dp[i][kk+1],dp[i-1][kk]+1);
        }
    }
    printf("%lld\n",dp[n][k]);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
stove.cpp:10:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld",&a[i]);
             ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 13 ms 13040 KB Output is correct
11 Correct 18 ms 15248 KB Output is correct
12 Correct 81 ms 36436 KB Output is correct
13 Correct 149 ms 59884 KB Output is correct
14 Correct 214 ms 81032 KB Output is correct
15 Correct 211 ms 83244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 13 ms 13040 KB Output is correct
11 Correct 18 ms 15248 KB Output is correct
12 Correct 81 ms 36436 KB Output is correct
13 Correct 149 ms 59884 KB Output is correct
14 Correct 214 ms 81032 KB Output is correct
15 Correct 211 ms 83244 KB Output is correct
16 Runtime error 99 ms 83244 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Halted 0 ms 0 KB -