Submission #77964

# Submission time Handle Problem Language Result Execution time Memory
77964 2018-10-01T13:26:52 Z aminra Cloud Computing (CEOI18_clo) C++14
0 / 100
677 ms 7220 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 7;
const int MAXS = (int)100006;
const int infint = (int)1e9;
const ll inf = (ll)1e18;
ll n, dp[MAXS], tmp[MAXS], sz;
struct machine{
	ll c, f, v;
} m[MAXN];
struct person{
	ll C, F, V;
} p[MAXN];
vector<ll> which[MAXN];
bool cmp(person a, person b)
{
	return a.F < b.F;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> m[i].c >> m[i].f >> m[i].v;
	cin >> sz;
	for (int i = 0; i < sz; i++)
		cin >> p[i].C >> p[i].F >> p[i].V;
	sort(p, p + sz, cmp);
	vector<ll> v;
	for (int i = 0; i < sz; i++)
		v.push_back(p[i].F);
	for (int i = 0; i < n; i++)
	{
		int idx = upper_bound(v.begin(), v.end(), m[i].f) - v.begin() - 1;
		if(idx != -1)
			which[idx].push_back(i);
	}
	for (int i = 0; i < MAXS; i++)
		dp[i] = -inf;
	dp[0] = 0;
	for (int i = sz - 1; i >= 0; i--)
	{
		for (auto u : which[i])
		{
			for (int j = 0; j < MAXS; j++)
				tmp[i] = -inf;
			for (int j = 0; j < MAXS; j++)
			{
				tmp[j] = dp[j];
				if(j >= m[u].c)
					tmp[j] = max(tmp[j], dp[j - m[u].c] - m[u].v);
			}
			for (int j = 0; j < MAXS; j++)
				dp[j] = tmp[j];
		}
		for (int j = 0; j < MAXS; j++)
		{
			if(j + p[i].F < MAXS)
				dp[j] = max(dp[j], dp[j + p[i].C] + p[i].V);	
		}		
	}
	ll mx = 0;
	for (int i = 0; i < MAXS; i++)
		mx = max(mx, dp[i]);
	cout << mx;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 6648 KB Output is correct
2 Correct 8 ms 6648 KB Output is correct
3 Correct 28 ms 6664 KB Output is correct
4 Correct 40 ms 6688 KB Output is correct
5 Incorrect 188 ms 6860 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6860 KB Output is correct
2 Correct 8 ms 6860 KB Output is correct
3 Correct 34 ms 6932 KB Output is correct
4 Correct 36 ms 6932 KB Output is correct
5 Correct 222 ms 7120 KB Output is correct
6 Correct 218 ms 7120 KB Output is correct
7 Incorrect 441 ms 7120 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 7120 KB Output is correct
2 Correct 13 ms 7120 KB Output is correct
3 Correct 29 ms 7120 KB Output is correct
4 Correct 31 ms 7120 KB Output is correct
5 Correct 122 ms 7120 KB Output is correct
6 Correct 114 ms 7168 KB Output is correct
7 Incorrect 94 ms 7168 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 7168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7168 KB Output is correct
2 Correct 21 ms 7168 KB Output is correct
3 Correct 179 ms 7168 KB Output is correct
4 Correct 395 ms 7168 KB Output is correct
5 Incorrect 677 ms 7220 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 6648 KB Output is correct
2 Correct 8 ms 6648 KB Output is correct
3 Correct 28 ms 6664 KB Output is correct
4 Correct 40 ms 6688 KB Output is correct
5 Incorrect 188 ms 6860 KB Output isn't correct
6 Halted 0 ms 0 KB -