Submission #736973

# Submission time Handle Problem Language Result Execution time Memory
736973 2023-05-06T11:58:10 Z study Cloud Computing (CEOI18_clo) C++17
100 / 100
431 ms 1368 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

struct Obj{
    int rate,cost,nbCores;
};

const int N = 1e5+1, inf = 1e18;

int dp[N];

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
    cin >> n;
    vector<Obj> objects;
    for (int i=0; i<n; ++i){
        int nbCores,rate,cost;
        cin >> nbCores >> rate >> cost;
        objects.push_back({rate,-cost,nbCores});
    }
    int m;
    cin >> m;
    for (int i=0; i<m; ++i){
        int nbCores,rate,cost;
        cin >> nbCores >> rate >> cost;
        objects.push_back({rate,cost,nbCores});
    }
    sort(objects.begin(),objects.end(),[](const Obj& a, const Obj& b){
        if (a.rate != b.rate) return a.rate > b.rate;
        return a.cost < b.cost;
    });
    fill_n(&dp[0],N,-inf);
    dp[0] = 0;
    for (auto obj:objects){
        if (obj.cost < 0){
            for (int i=N-1-obj.nbCores; i>=0; --i){
                if (dp[i] != -inf) dp[i+obj.nbCores] = max(dp[i+obj.nbCores],dp[i]+obj.cost); 
            }
        }
        else{
            for (int i=obj.nbCores; i<N; ++i){
                if (dp[i] != -inf) dp[i-obj.nbCores] = max(dp[i-obj.nbCores],dp[i]+obj.cost);
            }
        }
    }
    int ans = 0;
    for (int i=0; i<N; ++i) ans = max(ans,dp[i]);
    cout << ans; 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 9 ms 1108 KB Output is correct
4 Correct 16 ms 1108 KB Output is correct
5 Correct 163 ms 1116 KB Output is correct
6 Correct 136 ms 1236 KB Output is correct
7 Correct 155 ms 1236 KB Output is correct
8 Correct 144 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 11 ms 1108 KB Output is correct
4 Correct 11 ms 1104 KB Output is correct
5 Correct 103 ms 1156 KB Output is correct
6 Correct 93 ms 1152 KB Output is correct
7 Correct 204 ms 1232 KB Output is correct
8 Correct 221 ms 1236 KB Output is correct
9 Correct 232 ms 1200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 980 KB Output is correct
2 Correct 4 ms 980 KB Output is correct
3 Correct 22 ms 1100 KB Output is correct
4 Correct 16 ms 1128 KB Output is correct
5 Correct 33 ms 1108 KB Output is correct
6 Correct 42 ms 1120 KB Output is correct
7 Correct 65 ms 1108 KB Output is correct
8 Correct 43 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1096 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 179 ms 1192 KB Output is correct
4 Correct 142 ms 1108 KB Output is correct
5 Correct 336 ms 1236 KB Output is correct
6 Correct 381 ms 1236 KB Output is correct
7 Correct 377 ms 1324 KB Output is correct
8 Correct 378 ms 1320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 16 ms 1116 KB Output is correct
3 Correct 75 ms 1144 KB Output is correct
4 Correct 180 ms 1204 KB Output is correct
5 Correct 349 ms 1344 KB Output is correct
6 Correct 414 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 9 ms 1108 KB Output is correct
4 Correct 16 ms 1108 KB Output is correct
5 Correct 163 ms 1116 KB Output is correct
6 Correct 136 ms 1236 KB Output is correct
7 Correct 155 ms 1236 KB Output is correct
8 Correct 144 ms 1236 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 2 ms 1108 KB Output is correct
11 Correct 11 ms 1108 KB Output is correct
12 Correct 11 ms 1104 KB Output is correct
13 Correct 103 ms 1156 KB Output is correct
14 Correct 93 ms 1152 KB Output is correct
15 Correct 204 ms 1232 KB Output is correct
16 Correct 221 ms 1236 KB Output is correct
17 Correct 232 ms 1200 KB Output is correct
18 Correct 5 ms 980 KB Output is correct
19 Correct 4 ms 980 KB Output is correct
20 Correct 22 ms 1100 KB Output is correct
21 Correct 16 ms 1128 KB Output is correct
22 Correct 33 ms 1108 KB Output is correct
23 Correct 42 ms 1120 KB Output is correct
24 Correct 65 ms 1108 KB Output is correct
25 Correct 43 ms 1108 KB Output is correct
26 Correct 3 ms 1096 KB Output is correct
27 Correct 2 ms 1108 KB Output is correct
28 Correct 179 ms 1192 KB Output is correct
29 Correct 142 ms 1108 KB Output is correct
30 Correct 336 ms 1236 KB Output is correct
31 Correct 381 ms 1236 KB Output is correct
32 Correct 377 ms 1324 KB Output is correct
33 Correct 378 ms 1320 KB Output is correct
34 Correct 1 ms 1108 KB Output is correct
35 Correct 16 ms 1116 KB Output is correct
36 Correct 75 ms 1144 KB Output is correct
37 Correct 180 ms 1204 KB Output is correct
38 Correct 349 ms 1344 KB Output is correct
39 Correct 414 ms 1308 KB Output is correct
40 Correct 87 ms 1148 KB Output is correct
41 Correct 165 ms 1108 KB Output is correct
42 Correct 257 ms 1312 KB Output is correct
43 Correct 412 ms 1340 KB Output is correct
44 Correct 418 ms 1356 KB Output is correct
45 Correct 431 ms 1368 KB Output is correct
46 Correct 176 ms 1108 KB Output is correct
47 Correct 246 ms 1304 KB Output is correct
48 Correct 247 ms 1312 KB Output is correct