# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
173840 | 2020-01-05T14:05:57 Z | tourist | K개의 묶음 (IZhO14_blocks) | C++14 | 5 ms | 504 KB |
#include <iostream> #include <map> #include <vector> using namespace std; #define ll long long #define sz(x) (int)x.size() #define pii pair < int, int > #define endl "\n" #define METH ios::sync_with_stdio(0); cin.tie(0); #define BEGIN cout << "BEGIN" << endl; #define END cout << "END" << endl; const int N = 109; const int mod = 1e9 + 7; /// ANOTHER HASH MOD: 228228227 const int prime = 29; /// ANOTHER HASH PRIME: 997 const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8); int n, k, mx[N][N]; int a[N], ans, dp[N][N]; inline int read() { scanf("%d %d", &n, &k); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } return 0; } void calc(int l, int k, int sum) { if (k == 1) { ans = min(ans, mx[l][n] + sum); return; } for (int i = l; i <= n - k + 1; i++) { calc(i + 1, k - 1, sum + mx[l][i]); } } inline int solve() { ans = INF; for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { mx[i][j] = max(mx[i][j - 1], a[j]); } } for (int i = 1; i <= k; i++) { for (int j = 1; j <= n; j++) { dp[j][i] = INF; dp[j][1] = mx[1][j]; } } for (int i = 2; i <= k; i++) { for (int r = i; r <= n; r++) { for (int j = i; j <= r; j++) { dp[r][i] = min(dp[r][i], dp[j - 1][i - 1] + mx[j][r]); } } } //~ calc(1, k, 0); TODO: WHY TLE? cout << dp[n][k] << endl; return 0; } int main() { int t = 1; while (t--) { read(); if (n >= N) { cout << "FUCK YOU" << endl; return 0; } solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 380 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 3 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 380 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 420 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 504 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 380 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 380 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 252 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |