제출 #312200

#제출 시각아이디문제언어결과실행 시간메모리
312200BeanZCloud Computing (CEOI18_clo)C++14
0 / 100
50 ms640 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 2e3 + 5; ll dp[N][55]; struct viet{ ll c, f, v; bool operator <(const viet& o) const{ return f > o.f; } }a[N], b[N]; ll c[N], v[N], f[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n; cin >> n; for (int i = 1; i <= n; i++){ cin >> a[i].c >> a[i].f >> a[i].v; } for (int i = 0; i <= n; i++){ for (int j = 0; j <= 50; j++){ dp[i][j] = -1e18; } } dp[0][0] = 0; sort(a + 1, a + n + 1); ll ans = 0; ll m; cin >> m; for (int i = 1; i <= m; i++){ cin >> b[i].c >> b[i].f >> b[i].v; } sort(b + 1, b + m + 1); /* for (int j = 1; j <= n; j++){ /* for (int k = 0; k <= 50; k++){ if (k >= a[j].c) dp[j][k] = max(dp[j][k], dp[j - 1][k - a[j].c] - a[j].v); //cout << dp[j][k] << " " << j << " " << k << endl; } for (int k = 50; k >= 0; k--){ for (int i = 1; i <= m; i++){ if (k >= a[j].c) dp[j][k] = max(dp[j][k], dp[j - 1][k - a[j].c] - a[j].v); if ((k + c[i]) <= 50 && f[i] <= a[j].f) dp[j][k] = max(dp[j][k], dp[j][k + c[i]] + v[i]); ans = max(ans, dp[j][k]); } } }*/ for (int i = 1; i <= n; i++) dp[i][a[i].c] = -a[i].v; for (int i = 1; i <= m; i++){ //cout << dp[1][0] << endl; for (int j = 1; j <= n; j++){ for (int k = 0; k <= 50; k++){ if (k >= a[j].c) { dp[j][k] = max(dp[j][k], dp[j - 1][k - a[j].c] - a[j].v); } } for (int k = 49; k >= 0; k--) dp[j][k] = max(dp[j][k], dp[j][k + 1]); } for (int j = n; j >= 1; j--){ //cout << dp[1][1] << endl; for (int k = 0; k <= 50; k++){ //for (int i = 1; i <= m; i++){ //for (int k = 0; k <= 50; k++){ if ((k + b[i].c) <= 50 && b[i].f <= a[j].f) dp[j][k] = max(dp[j][k], dp[j][k + b[i].c] + b[i].v); ans = max(ans, dp[j][k]); //cout << dp[j][k] << " " << j << " " << k << endl; //} } } } cout << ans; } /* 2 48 4 1 41 2 1 2 42 2 2 10 4 5 */

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

clo.cpp:44:9: warning: "/*" within comment [-Wcomment]
   44 |         /*
      |          
clo.cpp: In function 'int main()':
clo.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   20 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   21 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...