# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
393386 | asbsfds | K blocks (IZhO14_blocks) | C++14 | 1098 ms | 89448 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long llint;
const int maxn = 2e5+10;
const int maxk = 110;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;
int n, k;
int niz[maxn];
int dp[maxk][maxn];
int main() {
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i++)
scanf("%d", niz+i);
memset(dp, inf, sizeof dp);
dp[0][0] = 0;
for (int i = 1; i <= k; i++) {
stack< pair<int, int> > s;
multiset< int > qs;
for (int j = 1; j <= n; j++) {
int mini = dp[i - 1][j - 1];
while (!s.empty() && s.top().first <= niz[j]) {
mini = min(mini, s.top().second);
qs.erase(qs.find(s.top().second + s.top().first));
s.pop();
}
s.push(make_pair(niz[j], mini));
//printf("inserting: %d %d\n", niz[j], mini);
qs.insert(mini + niz[j]);
//printf("ave: ");
//for (auto iter : qs) printf("%d ", iter); printf("\n");
dp[i][j] = *qs.begin();
}
}
printf("%d\n", dp[k][n]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |