Submission #219008

# Submission time Handle Problem Language Result Execution time Memory
219008 2020-04-03T11:21:21 Z pavement Cloud Computing (CEOI18_clo) C++17
54 / 100
392 ms 1408 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
typedef long double ld;

int N, M, f, c, v, idx, idx1, idx2, dp[100005];
tuple<int, int, int> F[100005], S[100005];
pair<int, bool> V[100005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1, c, f, v; i <= N; i++) {
		cin >> c >> f >> v;
		F[i] = mt(-f, c, v);
	}
	cin >> M;
	for (int i = 1; i <= M; i++) {
		cin >> c >> f >> v;
		S[i] = mt(-f, c, v);
	}
	sort(F + 1, F + 1 + N);
	sort(S + 1, S + 1 + M);
	for (; idx1 < N && idx2 < M; )
		if (get<0>(F[idx1 + 1]) < get<0>(S[idx2 + 1])) V[++idx] = mp(++idx1, 0);
		else V[++idx] = mp(++idx2, 1);
	while (idx1 < N) V[++idx] = mp(++idx1, 0);
	while (idx2 < M) V[++idx] = mp(++idx2, 1);
	for (int i = N + M; i >= 1; i--)
		if (V[i].second) for (int j = 100000; j >= get<1>(S[V[i].first]); j--)
			dp[j] = max(dp[j], dp[j - get<1>(S[V[i].first])] + get<2>(S[V[i].first]));
		else for (int j = 0; j <= 100000 - get<1>(F[V[i].first]); j++)
			dp[j] = max(dp[j], dp[j + get<1>(F[V[i].first])] - get<2>(F[V[i].first]));
	cout << dp[0] << '\n';
}

Compilation message

clo.cpp:15:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1152 KB Output is correct
2 Correct 5 ms 1152 KB Output is correct
3 Correct 15 ms 1152 KB Output is correct
4 Correct 26 ms 1152 KB Output is correct
5 Correct 191 ms 1308 KB Output is correct
6 Correct 190 ms 1280 KB Output is correct
7 Correct 200 ms 1280 KB Output is correct
8 Correct 199 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1152 KB Output is correct
2 Correct 6 ms 1152 KB Output is correct
3 Correct 15 ms 1152 KB Output is correct
4 Correct 15 ms 1152 KB Output is correct
5 Correct 92 ms 1152 KB Output is correct
6 Correct 91 ms 1152 KB Output is correct
7 Correct 201 ms 1280 KB Output is correct
8 Correct 196 ms 1280 KB Output is correct
9 Incorrect 191 ms 1284 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1152 KB Output is correct
2 Correct 8 ms 1152 KB Output is correct
3 Correct 25 ms 1272 KB Output is correct
4 Correct 22 ms 1152 KB Output is correct
5 Correct 39 ms 1152 KB Output is correct
6 Correct 39 ms 1152 KB Output is correct
7 Correct 52 ms 1152 KB Output is correct
8 Correct 52 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1200 KB Output is correct
2 Correct 20 ms 1152 KB Output is correct
3 Correct 64 ms 1152 KB Output is correct
4 Correct 199 ms 1280 KB Output is correct
5 Correct 389 ms 1408 KB Output is correct
6 Correct 392 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1152 KB Output is correct
2 Correct 5 ms 1152 KB Output is correct
3 Correct 15 ms 1152 KB Output is correct
4 Correct 26 ms 1152 KB Output is correct
5 Correct 191 ms 1308 KB Output is correct
6 Correct 190 ms 1280 KB Output is correct
7 Correct 200 ms 1280 KB Output is correct
8 Correct 199 ms 1280 KB Output is correct
9 Correct 5 ms 1152 KB Output is correct
10 Correct 6 ms 1152 KB Output is correct
11 Correct 15 ms 1152 KB Output is correct
12 Correct 15 ms 1152 KB Output is correct
13 Correct 92 ms 1152 KB Output is correct
14 Correct 91 ms 1152 KB Output is correct
15 Correct 201 ms 1280 KB Output is correct
16 Correct 196 ms 1280 KB Output is correct
17 Incorrect 191 ms 1284 KB Output isn't correct