이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "aliens.h"
using namespace std;
long long take_photos(int n, int m, int k, vector<int> l, vector<int> r)
{
vector<int> cv(m);
for (int i = 0; i < m; i++)
{
cv[i] = i + 1;
}
for (int i = 0; i < n; i++)
{
int x = min(l[i], r[i]);
int y = max(l[i], r[i]);
cv[y] = min(cv[y], x);
}
l.clear();
r.clear();
for (int i = 0; i < m; i++)
{
if (cv[i] <= i)
l.push_back(cv[i]), r.push_back(i);
}
n = l.size();
const long long INFLL = 1e18;
vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, INFLL));
dp[0][0] = 0;
for (int i = 1; i <= n; i++)
{
for (int g = 0; g < k; g++)
{
for (int p = 0; p < i; p++)
{
int L = l[p], R = r[i - 1];
int covto = -1;
if (p) covto = r[p - 1];
if (covto <= L)
dp[i][g + 1] = min(dp[i][g + 1], dp[p][g] + 1ll * (R - L + 1) * (R - L + 1));
else
dp[i][g + 1] = min(dp[i][g + 1], dp[p][g] + 1ll * (R - L + 1) * (R - L + 1) - 1ll * (covto - L + 1) * (covto - L + 1));
//cout << p << " " << i << " " << g + 1 << " " << dp[i][g + 1] << endl;
}
//cout << i << " " << g + 1 << " " << dp[i][g + 1] << endl;
}
}
return *min_element(dp[n].begin(), dp[n].end());
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |