Submission #1034424

# Submission time Handle Problem Language Result Execution time Memory
1034424 2024-07-25T13:41:05 Z warrenn Cloud Computing (CEOI18_clo) C++14
100 / 100
279 ms 1372 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct computer {
    int core, clock, price, type;
};
bool csortclock(computer a, computer b) {
	if(a.clock == b.clock)
		return a.type > b.type;
	else
    return a.clock < b.clock;
}

int main() {
    int n;
    cin >> n;
    computer a[n];
    int sum=0;
    vector<computer> v;
    for(int i = 0; i < n; ++i){
        cin >> a[i].core >> a[i].clock >> a[i].price, a[i].type = 0;
        sum+=a[i].core;
        v.push_back(a[i]);
    }
    int m;
    cin >> m;

    computer b[m];
    for(int i = 0; i < m; ++i){
        cin >> b[i].core >> b[i].clock >> b[i].price, b[i].type = 1;
        v.push_back(b[i]);
    }

  ll dp[sum + 1];
  for(int q=1;q<=sum;q++){
    dp[q]=-1e15;
  }
  dp[0] = 0;

	sort(v.begin(), v.end(), csortclock);
    for(int q=v.size()-1;q>=0;q--){
        computer c=v[q];
		if(c.type == 0) {
			for(int i =sum; i >= c.core; --i) {
				dp[i] = max(dp[i], dp[i - c.core] - c.price);
			}
		}
		else {
			for(int i = 0; i + c.core <=sum; ++i) {
				dp[i] = max(dp[i], dp[i + c.core] + c.price);
			}
		}
	}
	ll res = 0;
	for(int i = 0; i <= sum; ++i)
		res = max(res, dp[i]);
	cout << res << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 19 ms 680 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 70 ms 860 KB Output is correct
8 Correct 15 ms 604 KB Output is correct
9 Correct 113 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 436 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 1 ms 416 KB Output is correct
3 Correct 6 ms 556 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 123 ms 1048 KB Output is correct
6 Correct 235 ms 1112 KB Output is correct
7 Correct 233 ms 1116 KB Output is correct
8 Correct 209 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 14 ms 600 KB Output is correct
4 Correct 4 ms 444 KB Output is correct
5 Correct 244 ms 1372 KB Output is correct
6 Correct 221 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 19 ms 680 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 70 ms 860 KB Output is correct
16 Correct 15 ms 604 KB Output is correct
17 Correct 113 ms 1116 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 436 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 440 KB Output is correct
26 Correct 0 ms 436 KB Output is correct
27 Correct 1 ms 416 KB Output is correct
28 Correct 6 ms 556 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 123 ms 1048 KB Output is correct
31 Correct 235 ms 1112 KB Output is correct
32 Correct 233 ms 1116 KB Output is correct
33 Correct 209 ms 1112 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 14 ms 600 KB Output is correct
37 Correct 4 ms 444 KB Output is correct
38 Correct 244 ms 1372 KB Output is correct
39 Correct 221 ms 1112 KB Output is correct
40 Correct 16 ms 604 KB Output is correct
41 Correct 42 ms 604 KB Output is correct
42 Correct 5 ms 604 KB Output is correct
43 Correct 279 ms 1360 KB Output is correct
44 Correct 259 ms 1368 KB Output is correct
45 Correct 256 ms 1352 KB Output is correct
46 Correct 2 ms 344 KB Output is correct
47 Correct 5 ms 604 KB Output is correct
48 Correct 4 ms 552 KB Output is correct