# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
42263 | 2018-02-24T18:05:32 Z | RezwanArefin01 | Stove (JOI18_stove) | C++14 | 2 ms | 568 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; int a[22], n, K, dp[22][22]; int main(int argc, char const *argv[]) { #ifdef LOCAL_TESTING freopen("in", "r", stdin); #endif scanf("%d %d", &n, &K); if(n > 20) return 0; 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++) { for(int i = 1; i <= n; i++) { dp[k][i] = 1e9; for(int j = 1; j < i; j++) { dp[k][i] = min(dp[k][i], dp[k - 1][j] + a[i] - a[j + 1] + 1); } } } /* for(int i = 1; i <= K; i++) { for(int j = 1; j <= n; j++) cout << dp[i][j] << " "; cout << endl; }*/ cout << dp[K][n] << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 424 KB | Output is correct |
5 | Correct | 1 ms | 440 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 568 KB | Output is correct |
9 | Correct | 1 ms | 568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 424 KB | Output is correct |
5 | Correct | 1 ms | 440 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 568 KB | Output is correct |
9 | Correct | 1 ms | 568 KB | Output is correct |
10 | Incorrect | 1 ms | 568 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 424 KB | Output is correct |
5 | Correct | 1 ms | 440 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 568 KB | Output is correct |
9 | Correct | 1 ms | 568 KB | Output is correct |
10 | Incorrect | 1 ms | 568 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |