Submission #129080

# Submission time Handle Problem Language Result Execution time Memory
129080 2019-07-11T14:59:09 Z mraron Cloud Computing (CEOI18_clo) C++14
54 / 100
257 ms 262148 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=1LL<<60;
const ll mxc=10000;
struct dat {
	ll c,f,v;
	bool operator<(const dat& masik) const {
		if(f==masik.f) return c<masik.c;
		return f<masik.f;
	}
};
ll dp[4001][mxc+1];
int main() {
	int n,m;
	cin>>n;
	vector<dat> lst(n);
	for(int i=0;i<n;++i) {
		cin>>lst[i].c>>lst[i].f>>lst[i].v;
		lst[i].v=-lst[i].v;
	}
	cin>>m;
	lst.resize(n+m);
	for(int i=n;i<n+m;++i) {
		cin>>lst[i].c>>lst[i].f>>lst[i].v;
		lst[i].c=-lst[i].c;
	}
	sort(lst.begin(),lst.end());
	
	for(auto& i:dp[n+m]) i=-inf;
	dp[n+m][0]=0;
	
	for(int i=n+m-1;i>=0;i--) {
		//cerr<<lst[i].c<<"\n";
		for(int j=mxc;j>=0;j--) {
			dp[i][j]=dp[i+1][j];
			if(j-lst[i].c>=0 && j-lst[i].c<=mxc) {
				if(dp[i][j]>=-inf/2)
					dp[i][j]=max(dp[i][j], dp[i+1][j-lst[i].c]+lst[i].v);
				else
					dp[i][j]=dp[i+1][j-lst[i].c]+lst[i].v;
			}
		}
		//for(int j=0;j<=mxc;++j) cerr<<dp[i][j]<<" \n"[j==mxc];
	}
	
	ll ans=-inf;
	for(int i=0;i<=mxc;++i) ans=max(ans, dp[0][i]);
	cout<<ans<<"\n";
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 11 ms 8824 KB Output is correct
4 Correct 17 ms 16632 KB Output is correct
5 Correct 140 ms 150420 KB Output is correct
6 Correct 140 ms 150776 KB Output is correct
7 Correct 148 ms 158200 KB Output is correct
8 Correct 149 ms 158184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 10 ms 8696 KB Output is correct
4 Correct 10 ms 8696 KB Output is correct
5 Correct 71 ms 71888 KB Output is correct
6 Correct 69 ms 72000 KB Output is correct
7 Correct 152 ms 158328 KB Output is correct
8 Correct 149 ms 158324 KB Output is correct
9 Correct 146 ms 153336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 15 ms 14456 KB Output is correct
4 Correct 15 ms 14456 KB Output is correct
5 Correct 28 ms 28764 KB Output is correct
6 Correct 28 ms 28792 KB Output is correct
7 Correct 39 ms 39544 KB Output is correct
8 Correct 40 ms 39544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1656 KB Output is correct
2 Correct 3 ms 1656 KB Output is correct
3 Correct 111 ms 118520 KB Output is correct
4 Correct 133 ms 142840 KB Output is correct
5 Runtime error 254 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 888 KB Output is correct
2 Correct 14 ms 12920 KB Output is correct
3 Correct 63 ms 64376 KB Output is correct
4 Correct 147 ms 157116 KB Output is correct
5 Runtime error 257 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 11 ms 8824 KB Output is correct
4 Correct 17 ms 16632 KB Output is correct
5 Correct 140 ms 150420 KB Output is correct
6 Correct 140 ms 150776 KB Output is correct
7 Correct 148 ms 158200 KB Output is correct
8 Correct 149 ms 158184 KB Output is correct
9 Correct 2 ms 632 KB Output is correct
10 Correct 3 ms 1144 KB Output is correct
11 Correct 10 ms 8696 KB Output is correct
12 Correct 10 ms 8696 KB Output is correct
13 Correct 71 ms 71888 KB Output is correct
14 Correct 69 ms 72000 KB Output is correct
15 Correct 152 ms 158328 KB Output is correct
16 Correct 149 ms 158324 KB Output is correct
17 Correct 146 ms 153336 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 4 ms 2808 KB Output is correct
20 Correct 15 ms 14456 KB Output is correct
21 Correct 15 ms 14456 KB Output is correct
22 Correct 28 ms 28764 KB Output is correct
23 Correct 28 ms 28792 KB Output is correct
24 Correct 39 ms 39544 KB Output is correct
25 Correct 40 ms 39544 KB Output is correct
26 Correct 3 ms 1656 KB Output is correct
27 Correct 3 ms 1656 KB Output is correct
28 Correct 111 ms 118520 KB Output is correct
29 Correct 133 ms 142840 KB Output is correct
30 Runtime error 254 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Halted 0 ms 0 KB -