# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
253399 | vovamr | K개의 묶음 (IZhO14_blocks) | C++14 | 372 ms | 84600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define inf 1e18
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector <ll> v(n);
for (auto &i : v) cin >> i;
vector < vector <ll> > dp(n + 1, vector <ll> (k + 1));
for (int i = 1; i <= n; ++i) dp[i][0] = inf;
stack < pair <ll, ll> > st;
for (int i = 1; i <= k; ++i) {
while (!st.empty()) st.pop();
dp[i][i] = dp[i - 1][i - 1] + v[i - 1]; st.push({v[i - 1], dp[i - 1][i - 1]});
for (int j = i + 1; j <= n; ++j) {
ll c = dp[j - 1][i - 1];
while (!st.empty() && st.top().fi <= v[j - 1]) {
c = min(c, st.top().se);
st.pop();
}
# | 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... |