# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1040379 | vjudge1 | K개의 묶음 (IZhO14_blocks) | C++17 | 1046 ms | 83288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define Y8o "K blocks"
#define maxn (int) 1e5 + 5
#define ll long long
#define pii pair<ll, ll>
#define gb(i, j) ((i >> j) & 1)
#define all(x) x.begin(), x.end()
#define _left id * 2, l, mid
#define _right id * 2 + 1, mid + 1, r
//#define f first
//#define s second
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll GetRandom(ll l, ll r) {
return uniform_int_distribution<ll> (l, r) (rng);
}
void iof() {
if(fopen(Y8o".in", "r"))
{
freopen(Y8o".in", "r", stdin);
freopen(Y8o".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(NULL), cout.tie(NULL);
}
void ctime() {
cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
int n, k;
int a[maxn];
ll s[maxn], dp[105][maxn];
void solve()
{
cin >> n >> k;
for(int i = 1; i <= n; i ++) cin >> a[i], s[i] = s[i - 1] + a[i];
memset(dp, 0x3f, sizeof dp);
int mx2 = 0;
for(int i = 1; i <= n; i ++) mx2 = max(mx2, a[i]), dp[1][i] = mx2;
for(int i = 2; i <= k; i ++) {
for(int j = 1; j <= n; j ++) {
int mx = 0;
for(int t = j; t >= 1; t --) {
mx = max(mx, a[t]);
dp[i][j] = min(dp[i][j], dp[i - 1][t - 1] + mx);
}
}
}
cout << dp[k][n];
}
int main()
{
iof();
int nTest = 1;
// cin >> nTest;
while(nTest --) {
solve();
}
ctime();
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... |