Submission #129174

# Submission time Handle Problem Language Result Execution time Memory
129174 2019-07-11T18:57:59 Z mraron Cloud Computing (CEOI18_clo) C++14
100 / 100
2664 ms 2168 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=1LL<<50;
const ll mxc=101000;
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[2][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)&1]) i=-inf;
	dp[(n+m)&1][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&1][j]=dp[(i+1)&1][j];
			if(j!=mxc) dp[i&1][j]=max(dp[i&1][j], dp[i&1][j+1]);
			
			if(j-lst[i].c>=0 && j-lst[i].c<=mxc) {
				dp[i&1][j]=max(dp[i&1][j], dp[(i+1)&1][j-lst[i].c]+lst[i].v);
			}
		}
		//for(int j=0;j<=mxc;++j) cerr<<dp[i][j]<<" \n"[j==mxc];
	}
	
	cout<<dp[0][0]<<"\n";
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1912 KB Output is correct
2 Correct 4 ms 1912 KB Output is correct
3 Correct 76 ms 1912 KB Output is correct
4 Correct 144 ms 1912 KB Output is correct
5 Correct 1265 ms 2040 KB Output is correct
6 Correct 1279 ms 2040 KB Output is correct
7 Correct 1334 ms 2040 KB Output is correct
8 Correct 1334 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1896 KB Output is correct
2 Correct 11 ms 1912 KB Output is correct
3 Correct 74 ms 2060 KB Output is correct
4 Correct 75 ms 2012 KB Output is correct
5 Correct 614 ms 1912 KB Output is correct
6 Correct 612 ms 2040 KB Output is correct
7 Correct 1345 ms 2168 KB Output is correct
8 Correct 1352 ms 2168 KB Output is correct
9 Correct 1301 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1912 KB Output is correct
2 Correct 23 ms 1912 KB Output is correct
3 Correct 123 ms 1912 KB Output is correct
4 Correct 123 ms 1912 KB Output is correct
5 Correct 246 ms 1964 KB Output is correct
6 Correct 246 ms 1956 KB Output is correct
7 Correct 334 ms 2040 KB Output is correct
8 Correct 334 ms 1964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1912 KB Output is correct
2 Correct 14 ms 1912 KB Output is correct
3 Correct 1018 ms 2028 KB Output is correct
4 Correct 1208 ms 2040 KB Output is correct
5 Correct 2505 ms 2168 KB Output is correct
6 Correct 2650 ms 2040 KB Output is correct
7 Correct 2656 ms 2168 KB Output is correct
8 Correct 2605 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1912 KB Output is correct
2 Correct 109 ms 1912 KB Output is correct
3 Correct 545 ms 2012 KB Output is correct
4 Correct 1333 ms 2040 KB Output is correct
5 Correct 2628 ms 2168 KB Output is correct
6 Correct 2655 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1912 KB Output is correct
2 Correct 4 ms 1912 KB Output is correct
3 Correct 76 ms 1912 KB Output is correct
4 Correct 144 ms 1912 KB Output is correct
5 Correct 1265 ms 2040 KB Output is correct
6 Correct 1279 ms 2040 KB Output is correct
7 Correct 1334 ms 2040 KB Output is correct
8 Correct 1334 ms 2168 KB Output is correct
9 Correct 5 ms 1896 KB Output is correct
10 Correct 11 ms 1912 KB Output is correct
11 Correct 74 ms 2060 KB Output is correct
12 Correct 75 ms 2012 KB Output is correct
13 Correct 614 ms 1912 KB Output is correct
14 Correct 612 ms 2040 KB Output is correct
15 Correct 1345 ms 2168 KB Output is correct
16 Correct 1352 ms 2168 KB Output is correct
17 Correct 1301 ms 2168 KB Output is correct
18 Correct 23 ms 1912 KB Output is correct
19 Correct 23 ms 1912 KB Output is correct
20 Correct 123 ms 1912 KB Output is correct
21 Correct 123 ms 1912 KB Output is correct
22 Correct 246 ms 1964 KB Output is correct
23 Correct 246 ms 1956 KB Output is correct
24 Correct 334 ms 2040 KB Output is correct
25 Correct 334 ms 1964 KB Output is correct
26 Correct 14 ms 1912 KB Output is correct
27 Correct 14 ms 1912 KB Output is correct
28 Correct 1018 ms 2028 KB Output is correct
29 Correct 1208 ms 2040 KB Output is correct
30 Correct 2505 ms 2168 KB Output is correct
31 Correct 2650 ms 2040 KB Output is correct
32 Correct 2656 ms 2168 KB Output is correct
33 Correct 2605 ms 2140 KB Output is correct
34 Correct 7 ms 1912 KB Output is correct
35 Correct 109 ms 1912 KB Output is correct
36 Correct 545 ms 2012 KB Output is correct
37 Correct 1333 ms 2040 KB Output is correct
38 Correct 2628 ms 2168 KB Output is correct
39 Correct 2655 ms 2140 KB Output is correct
40 Correct 684 ms 1996 KB Output is correct
41 Correct 1287 ms 2040 KB Output is correct
42 Correct 2011 ms 2124 KB Output is correct
43 Correct 2664 ms 2168 KB Output is correct
44 Correct 2654 ms 2044 KB Output is correct
45 Correct 2649 ms 2168 KB Output is correct
46 Correct 1328 ms 2068 KB Output is correct
47 Correct 1990 ms 2168 KB Output is correct
48 Correct 1963 ms 2140 KB Output is correct