Submission #312198

#TimeUsernameProblemLanguageResultExecution timeMemory
312198BeanZCloud Computing (CEOI18_clo)C++14
0 / 100
176 ms52088 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[255][255 * 50]; struct viet{ ll c, f, v; bool operator <(const viet& o) const{ return f > o.f; } }a[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 * 250); 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 >> c[i] >> f[i] >> v[i]; } /* 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 * 250); 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 j = n; j >= 1; j--){ //cout << dp[1][1] << endl; for (int k = 0; k <= (50 * 250); k++){ //for (int i = 1; i <= m; i++){ //for (int k = 0; k <= 50; k++){ if ((k + c[i]) <= (50 * 250) && 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]); //cout << dp[j][k] << " " << j << " " << k << endl; //} } } } cout << ans; } /* 4 4 2200 700 2 1800 10 20 2550 9999 4 2000 750 3 1 1500 300 6 1900 1500 3 2400 4550 */

Compilation message (stderr)

clo.cpp:43:9: warning: "/*" within comment [-Wcomment]
   43 |         /*
      |          
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...