Submission #552500

#TimeUsernameProblemLanguageResultExecution timeMemory
552500MilosMilutinovicCloud Computing (CEOI18_clo)C++14
36 / 100
12 ms1108 KiB
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const LL INF = 1000000000000000000LL;

int n, m, c[2005], f[2005], v[2005], C[2005], F[2005], V[2005];
LL dp[2][20005];
pair<PII, int> ord[4005];
int main()
{
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d%d%d", &c[i], &f[i], &v[i]);
		ord[i] = MP(MP(-f[i], 0), i);
	}
	scanf("%d", &m);
	rep(i, m) {
		scanf("%d%d%d", &C[i], &F[i], &V[i]);
		ord[i + n] = MP(MP(-F[i], 1), i);
	}
	sort(ord, ord + n + m);
	rep(i, 2) rep(j, n * 51) dp[i][j] = -INF;
	dp[1][0] = 0;
	rep(i, n + m) {
		int ii = ((i & 1) ^ 1);
		int id = ord[i].second;
		rep(j, n * 51) dp[i & 1][j] = dp[ii][j];
		if(ord[i].first.second == 0) {
			for(int j = n * 51 - 1; j >= c[id]; j--) {
				dp[i & 1][j] = max(dp[i & 1][j], dp[ii][j - c[id]] - v[id]);
			}
		} else {
			for(int j = n * 51 - 1; j >= C[id]; j--) {
				dp[i & 1][j - C[id]] = max(dp[i & 1][j - C[id]], dp[ii][j] + V[id]);
			}
		}
	}
	LL ans = 0;
	rep(i, 2) rep(j, n * 51) ans = max(ans, dp[i][j]);
	printf("%lld\n", ans);
	return 0;
}

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
clo.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d%d%d", &c[i], &f[i], &v[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d", &m);
      |  ~~~~~^~~~~~~~~~
clo.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d%d%d", &C[i], &F[i], &V[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...