Submission #42264

# Submission time Handle Problem Language Result Execution time Memory
42264 2018-02-24T18:10:08 Z RezwanArefin01 Stove (JOI18_stove) C++14
50 / 100
49 ms 47724 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

int a[5001], n, K, dp[5001][5001];

int main(int argc, char const *argv[]) {
	scanf("%d %d", &n, &K);
	for(int i = 1; i <= n; i++) 
		scanf("%d", &a[i]);

	for(int i = 1; i <= n; i++) 
		dp[1][i] = a[i] - a[1] + 1; 

	for(int k = 2; k <= K; k++) {
		int Min = 1e9;
		for(int i = 1; i <= n; i++) {
			dp[k][i] = a[i] + Min + 1;
			if(i < n) Min = min(Min, dp[k - 1][i] - a[i + 1]);
		}
	}	
	cout << dp[K][n] << endl;
}

Compilation message

stove.cpp: In function 'int main(int, const char**)':
stove.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &K);
                        ^
stove.cpp:12:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
                     ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 496 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 548 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 1 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 496 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 548 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 1 ms 548 KB Output is correct
10 Correct 2 ms 796 KB Output is correct
11 Correct 4 ms 2212 KB Output is correct
12 Correct 17 ms 16300 KB Output is correct
13 Correct 33 ms 32108 KB Output is correct
14 Correct 45 ms 46192 KB Output is correct
15 Correct 49 ms 47724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 496 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 548 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 1 ms 548 KB Output is correct
10 Correct 2 ms 796 KB Output is correct
11 Correct 4 ms 2212 KB Output is correct
12 Correct 17 ms 16300 KB Output is correct
13 Correct 33 ms 32108 KB Output is correct
14 Correct 45 ms 46192 KB Output is correct
15 Correct 49 ms 47724 KB Output is correct
16 Execution timed out 3 ms 47724 KB Time limit exceeded (wall clock)
17 Halted 0 ms 0 KB -