제출 #1063234

#제출 시각아이디문제언어결과실행 시간메모리
1063234hahahahaCloud Computing (CEOI18_clo)C++17
18 / 100
212 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e3+10; const int maxc = 51; const ll inf = 2e18+10; struct Obj { int c, f, v; } a[maxn], b[maxn]; int n, m; ll dp[maxn][maxn][maxc]; void upd(ll &a, ll b) { a = max(a, b); } bool comp(Obj a, Obj b) { return a.f > b.f; } int main(void) { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d %d %d", &a[i].c, &a[i].f, &a[i].v); scanf("%d", &m); for (int i = 1; i <= m; i++) scanf("%d %d %d", &b[i].c, &b[i].f, &b[i].v); sort(a+1, a+n+1, comp); sort(b+1, b+m+1, comp); for (int i = n; i >= 0; i--) { for (int j = m; j >= 1; j--) { for (int c = maxc-1; c >= 0; c--) { if (a[i+1].f < b[j].f && c > 0 && c < b[j].c) { upd(dp[i][j][c], dp[i][j+1][c]); continue; } upd(dp[i][j][c], dp[i+1][j][c]); upd(dp[i][j][c], dp[i][j+1][c]); if (c >= b[j].c) upd(dp[i][j][c], 1ll*b[j].v + dp[i][j+1][c-b[j].c]); if (i < n && c < maxc && a[i+1].f >= b[j].f) upd(dp[i][j][c], dp[i+1][j][c+a[i+1].c] - 1ll*a[i+1].v); } } } printf("%lld\n", max(0ll, dp[0][1][0])); }

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'int main()':
clo.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
clo.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d %d %d", &a[i].c, &a[i].f, &a[i].v);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  scanf("%d", &m);
      |  ~~~~~^~~~~~~~~~
clo.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%d %d %d", &b[i].c, &b[i].f, &b[i].v);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...