## 답안 #997147

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
997147 2024-06-11T18:08:44 Z daffuwu Cloud Computing (CEOI18_clo) C++14
18 / 100
183 ms 3228 KB
```#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second

long long n, m, dp1[2][100069], dp2[2][100069], c, f, v, ps1, ps2, ans, mn;

int main()
{
long long i, sm;
// for (sm=1; sm<=100000) dp1[0][sm] = 0;
scanf("%lld", &n);
for (i=1; i<=n; i++)
{
scanf("%lld%lld%lld", &c, &f, &v);
for (sm=0; sm<=ps1+c; sm++)
{
if (sm<=ps1) dp1[i%2][sm] = dp1[(i+1)%2][sm];
else dp1[i%2][sm] = 1e15;
if (sm>=c) dp1[i%2][sm] = min(dp1[i%2][sm], dp1[(i+1)%2][sm-c]+v);
}
ps1 += c;
}
scanf("%lld", &m);
for (i=1; i<=m; i++)
{
scanf("%lld%lld%lld", &c, &f, &v);
for (sm=0; sm<=ps2+c; sm++)
{
if (sm<=ps2) dp2[i%2][sm] = dp2[(i+1)%2][sm];
else dp2[i%2][sm] = -1e15;
if (sm>=c) dp2[i%2][sm] = max(dp2[i%2][sm], dp2[(i+1)%2][sm-c]+v);
}
ps2 += c;
}
for (sm=ps1-1; sm>=0; sm--) dp1[n%2][sm] = min(dp1[n%2][sm], dp1[n%2][sm+1]);
mn = min(ps1, ps2);
for (sm=0; sm<=mn; sm++)
{
// printf("dp1[%lld][%lld] = %lld dp2[%lld][%lld] = %lld\n", n, sm, dp1[n%2][sm], m, sm, dp2[m%2][sm]);
ans = max(ans, dp2[m%2][sm]-dp1[n%2][sm]);
}
printf("%lld\n", ans);
}```

### Compilation message

```clo.cpp: In function 'int main()':
clo.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 |     scanf("%lld", &n);
|     ~~~~~^~~~~~~~~~~~
clo.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 |         scanf("%lld%lld%lld", &c, &f, &v);
|         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 |     scanf("%lld", &m);
|     ~~~~~^~~~~~~~~~~~
clo.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 |         scanf("%lld%lld%lld", &c, &f, &v);
|         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~```

#### Subtask #1 0 / 18.0

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 44 ms 1224 KB Output isn't correct
6 Halted 0 ms 0 KB -

#### Subtask #2 0 / 18.0

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 444 KB Output is correct
2 Incorrect 0 ms 440 KB Output isn't correct
3 Halted 0 ms 0 KB -

#### Subtask #3 0 / 18.0

# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -

#### Subtask #4 18.0 / 18.0

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 9 ms 604 KB Output is correct
5 Correct 88 ms 1956 KB Output is correct
6 Correct 162 ms 3228 KB Output is correct
7 Correct 183 ms 3156 KB Output is correct
8 Correct 149 ms 3152 KB Output is correct

#### Subtask #5 0 / 18.0

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -

#### Subtask #6 0 / 10.0

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 44 ms 1224 KB Output isn't correct
6 Halted 0 ms 0 KB -