답안 #943635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
943635 2024-03-11T17:13:08 Z vjudge1 Cloud Computing (CEOI18_clo) C++17
100 / 100
630 ms 2140 KB
#include <bits/stdc++.h>

using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define int long long
const int N = 2e5;
const int mod = 1e16 + 7;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector<array<int, 4> > w;
    for(int i = 0;i < n; i++){
        int c, f, cost; cin >> c >> f >> cost;
         w.push_back({c, f, cost, 1});
    }
    int m; cin >> m;
    for(int i = 0;i < m; i++){
        int c, f, cost; cin >> c >> f >> cost;
        w.push_back({c, f, cost, 0});
    }
    
    sort(all(w), [&](auto A, auto B){
        if(A[1] == B[1]) return A[3] > B[3];
        return A[1] > B[1];
    });
    vector<int> dp(N+5, -mod);
    dp[0] = 0;
    
    for(auto [c, f, cost, type] : w){
        if(type == 1){
            for(int i = N; i >= c; i--){
                dp[i] = max(dp[i], dp[i-c] - cost);
            }
        }else{
            for(int i = 0; i <= N - c; i++){
                dp[i] = max(dp[i], dp[i+c] + cost);
            }
        }
    }
    
    
    cout << *max_element(all(dp));
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 1 ms 1880 KB Output is correct
3 Correct 17 ms 1884 KB Output is correct
4 Correct 31 ms 1880 KB Output is correct
5 Correct 281 ms 2140 KB Output is correct
6 Correct 302 ms 2136 KB Output is correct
7 Correct 300 ms 2136 KB Output is correct
8 Correct 299 ms 2136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 3 ms 2136 KB Output is correct
3 Correct 17 ms 1884 KB Output is correct
4 Correct 17 ms 1884 KB Output is correct
5 Correct 135 ms 1884 KB Output is correct
6 Correct 139 ms 1880 KB Output is correct
7 Correct 296 ms 2136 KB Output is correct
8 Correct 302 ms 2140 KB Output is correct
9 Correct 285 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1880 KB Output is correct
2 Correct 6 ms 1884 KB Output is correct
3 Correct 27 ms 1884 KB Output is correct
4 Correct 31 ms 1884 KB Output is correct
5 Correct 54 ms 1884 KB Output is correct
6 Correct 63 ms 1880 KB Output is correct
7 Correct 75 ms 1880 KB Output is correct
8 Correct 74 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1884 KB Output is correct
2 Correct 5 ms 1884 KB Output is correct
3 Correct 219 ms 2140 KB Output is correct
4 Correct 270 ms 2136 KB Output is correct
5 Correct 555 ms 2140 KB Output is correct
6 Correct 614 ms 2136 KB Output is correct
7 Correct 591 ms 2140 KB Output is correct
8 Correct 571 ms 2136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 25 ms 1880 KB Output is correct
3 Correct 120 ms 1884 KB Output is correct
4 Correct 313 ms 2140 KB Output is correct
5 Correct 586 ms 2140 KB Output is correct
6 Correct 629 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 1 ms 1880 KB Output is correct
3 Correct 17 ms 1884 KB Output is correct
4 Correct 31 ms 1880 KB Output is correct
5 Correct 281 ms 2140 KB Output is correct
6 Correct 302 ms 2136 KB Output is correct
7 Correct 300 ms 2136 KB Output is correct
8 Correct 299 ms 2136 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 3 ms 2136 KB Output is correct
11 Correct 17 ms 1884 KB Output is correct
12 Correct 17 ms 1884 KB Output is correct
13 Correct 135 ms 1884 KB Output is correct
14 Correct 139 ms 1880 KB Output is correct
15 Correct 296 ms 2136 KB Output is correct
16 Correct 302 ms 2140 KB Output is correct
17 Correct 285 ms 2140 KB Output is correct
18 Correct 6 ms 1880 KB Output is correct
19 Correct 6 ms 1884 KB Output is correct
20 Correct 27 ms 1884 KB Output is correct
21 Correct 31 ms 1884 KB Output is correct
22 Correct 54 ms 1884 KB Output is correct
23 Correct 63 ms 1880 KB Output is correct
24 Correct 75 ms 1880 KB Output is correct
25 Correct 74 ms 1880 KB Output is correct
26 Correct 5 ms 1884 KB Output is correct
27 Correct 5 ms 1884 KB Output is correct
28 Correct 219 ms 2140 KB Output is correct
29 Correct 270 ms 2136 KB Output is correct
30 Correct 555 ms 2140 KB Output is correct
31 Correct 614 ms 2136 KB Output is correct
32 Correct 591 ms 2140 KB Output is correct
33 Correct 571 ms 2136 KB Output is correct
34 Correct 2 ms 1884 KB Output is correct
35 Correct 25 ms 1880 KB Output is correct
36 Correct 120 ms 1884 KB Output is correct
37 Correct 313 ms 2140 KB Output is correct
38 Correct 586 ms 2140 KB Output is correct
39 Correct 629 ms 2140 KB Output is correct
40 Correct 152 ms 1880 KB Output is correct
41 Correct 332 ms 2136 KB Output is correct
42 Correct 445 ms 2136 KB Output is correct
43 Correct 587 ms 2136 KB Output is correct
44 Correct 597 ms 2140 KB Output is correct
45 Correct 630 ms 2136 KB Output is correct
46 Correct 300 ms 2140 KB Output is correct
47 Correct 483 ms 2140 KB Output is correct
48 Correct 431 ms 2140 KB Output is correct