# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
244802 | kshitij_sodani | K개의 묶음 (IZhO14_blocks) | C++17 | 256 ms | 4628 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
let dp[i][j] denote minimum answer for splitting first i in j segments
naive dp is n^2*k
we can optimize using observations
let x be max index element with a_x>a_i(classical problem in o(N) using stacks)
notice answer is min(dp[x][j],min(dp[x][j-1],dp[x+1][j-1],,,,,,,,(dp[i-1][j-1]))+a_i)
observe that x to (i-1) segments intersect only at endpoints
can be done using stack
amortized O(nk)
note nk*log(n) wit segment tree gets TLE
I first tried that
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'
int n,k;
int dp[100001];
int dp2[100001];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |