Submission #1105246

# Submission time Handle Problem Language Result Execution time Memory
1105246 2024-10-25T20:36:34 Z xydwe12312 Cloud Computing (CEOI18_clo) C++14
18 / 100
234 ms 1412 KB
#include <bits/stdc++.h>
using namespace std;

// Macros
#define pb          push_back
#define pf          push_front
#define ff          first
#define ss          second
#define all(v)      v.begin(), v.end()
#define rall(v)     v.rbegin(), v.rend()
#define up(v)       upper_bound(v)
#define low(v)      lower_bound(v)

// Read and Print
#define read(a, n) for(ll i = 0; i < n; ++i) cin >> a[i];
#define print(a, n) for(ll i = 0; i < n; ++i){ cout << a[i] << " ";} cout << "\n";
#define endl "\n"
#define sp " "

// Typedefs
typedef long long ll;
typedef long double ld;
typedef long long int lli;
typedef pair<ll, ll> pll;
typedef pair<lli, lli> plli;
typedef pair<ll, ll> pii; // Changed to ll
typedef vector<lli> vi;
typedef vector<vector<lli>> vvi;
using vec = vector<ll>; // Changed to ll

// Constants
const ll mxn = 1e6 + 5;
const ll mod = 1e9 + 7;

// Solve
const ll N = 1e5 + 5;

void solve() {
	ll n;
	cin >> n;
	vi c(n), f(n), v(n);
	vector<tuple<ll, ll, ll>> a; // Changed to ll
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		cin >> c[i] >> f[i] >> v[i];
		a.pb({f[i], c[i], -v[i]});
		sum += c[i];
	}
	ll m;  // Changed to ll
	cin >> m;
	vector<ll> C(m), F(m), V(m); // Changed to ll
	for (ll i = 0; i < m; i++) { // Changed to ll
		cin >> C[i] >> F[i] >> V[i];
		a.pb({F[i], C[i], V[i]});
	}
	sort(rall(a));
	vi dp(sum + 1, -1e8);
	dp[0] = 0;
	for (auto [i, j, k] : a) {
		if (k > 0) {
			for (ll l = j; l <= sum; l++) { // Changed to ll
				dp[l - j] = max(dp[l - j], dp[l] + k);
			}
		} else {
			for (ll l = sum - j; l >= 0; l--) { // Changed to ll
				dp[l + j] = max(dp[l + j], dp[l] + k);
			}
		}
	}
	sort(rall(dp));
	cout << dp[0] << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Compilation message

clo.cpp: In function 'void solve()':
clo.cpp:59:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   59 |  for (auto [i, j, k] : a) {
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Incorrect 1 ms 472 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 16 ms 592 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Incorrect 75 ms 848 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 15 ms 592 KB Output is correct
4 Correct 4 ms 592 KB Output is correct
5 Correct 226 ms 1412 KB Output is correct
6 Correct 234 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Incorrect 1 ms 472 KB Output isn't correct
7 Halted 0 ms 0 KB -