Submission #617627

# Submission time Handle Problem Language Result Execution time Memory
617627 2022-08-01T12:30:54 Z usuyus Cloud Computing (CEOI18_clo) C++14
54 / 100
309 ms 1260 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int n; cin >> n;
	vector<array<ll, 3>> pts;

	int s = 0;
	for (int i=0; i<n; i++) {
		ll c, v, f; cin >> c >> f >> v;
		pts.push_back({f, c, -v});
		s += c;
	}

	int m; cin >> m;
	for (int i=0; i<m; i++) {
		ll c, v, f; cin >> c >> f >> v;
		pts.push_back({f, c, v});
	}

	sort(pts.rbegin(), pts.rend());

	vector<ll> dp(s+1, -1e18);
	dp[0] = 0;

	for (auto [f, c, v] : pts) {
		// cout << f << ' ' << c << ' ' << v << endl;
		if (v > 0) { // cust
			for (int i=c; i<=s; i++) {
				dp[i - c] = max(dp[i - c], dp[i] + v);
			}
		} else { // comp
			for (int i=s-c; i>=0; i--) {
				dp[i + c] = max(dp[i + c], dp[i] + v);
			}
		}
	}

	ll ans = 0;
	for (ll x : dp) ans = max(ans, x);
	cout << ans << endl;
}

Compilation message

clo.cpp: In function 'int main()':
clo.cpp:29:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |  for (auto [f, c, v] : pts) {
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 22 ms 456 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 115 ms 860 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Incorrect 147 ms 1108 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 17 ms 468 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 306 ms 1260 KB Output is correct
6 Correct 309 ms 1240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 0 ms 224 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 22 ms 456 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 115 ms 860 KB Output is correct
16 Correct 19 ms 468 KB Output is correct
17 Incorrect 147 ms 1108 KB Output isn't correct
18 Halted 0 ms 0 KB -