| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 132804 | SamAnd | Cloud Computing (CEOI18_clo) | C++17 | 1243 ms | 2296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
const long long INF = 100005000000009;
struct ban
{
bool z;
int q, x, g;
};
bool operator<(const ban& a, const ban& b)
{
if (a.x < b.x)
return true;
if (a.x > b.x)
return false;
return a.z < b.z;
}
int n, m;
ban a[N + N];
long long dp[N * 55];
long long ndp[N * 55];
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
{
a[i].z = true;
scanf("%d%d%d", &a[i].q, &a[i].x, &a[i].g);
}
scanf("%d", &m);
for (int i = n + 1; i <= n + m; ++i)
{
a[i].z = false;
scanf("%d%d%d", &a[i].q, &a[i].x, &a[i].g);
}
sort(a + 1, a + n + m + 1);
for (int i = 1; i <= n * 50; ++i)
dp[i] = -INF;
for (int i = n + m; i >= 1; --i)
{
memset(ndp, -INF, sizeof ndp);
if (a[i].z)
{
for (int j = 0; j <= n * 50; ++j)
{
ndp[j] = max(ndp[j], dp[j]);
if (j + a[i].q <= n * 50)
ndp[j + a[i].q] = max(ndp[j + a[i].q], dp[j] - a[i].g);
}
}
else
{
for (int j = 0; j <= n * 50; ++j)
{
ndp[j] = max(ndp[j], dp[j]);
if (j - a[i].q >= 0)
ndp[j - a[i].q] = max(ndp[j - a[i].q], dp[j] + a[i].g);
}
}
memcpy(dp, ndp, sizeof ndp);
}
long long ans = 0;
for (int j = 0; j <= n * 50; ++j)
ans = max(ans, dp[j]);
cout << ans << endl;
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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
