답안 #443872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
443872 2021-07-12T10:19:15 Z Haruto810198 Cloud Computing (CEOI18_clo) C++17
100 / 100
588 ms 2500 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())

#define vi vector<int>
#define pii pair<int, int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF = 2147483647;
const int LNF = INF*INF;
const int MOD = 1000000007;
const int mod = 998244353;
const double eps = 1e-12;

const int MAX = 2010;

int n, m;
vi cpu[MAX]; /// computers: {cores, rate, price}
vi work[MAX]; /// works: {cores, rate, price}

vector<vi> items;

int dp[50 * MAX + 1];
int tmp[50 * MAX + 1];

bool cmp_by_rate(vi a, vi b){
    if(a[1] == b[1]) return (a[0] > b[0]);
    return (a[1] > b[1]);
}

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    FOR(i, 0, n-1, 1){
        int c, r, p;
        cin>>c>>r>>p;
        cpu[i] = {c, r, p};
        items.pb({c, r, -p});
    }
    //sort(cpu, cpu+n, cmp_by_rate);

    cin>>m;
    FOR(i, 0, m-1, 1){
        int c, r, p;
        cin>>c>>r>>p;
        work[i] = {c, r, p};
        items.pb({-c, r, p});
    }
    //sort(work, work+m, cmp_by_rate);

    sort(items.begin(), items.end(), cmp_by_rate);

    dp[0] = 0;
    FOR(i, 1, 50*MAX, 1){
        dp[i] = -LNF;
    }

    for(auto I : items){

        int w = I[0], v = I[2];

        FOR(i, 0, 50*MAX, 1){
            if(0 <= i-w and i-w <= 50*MAX){
                tmp[i] = max(dp[i], dp[i - w] + v);
            }
            else{
                tmp[i] = dp[i];
            }
        }

        FOR(i, 0, 50*MAX, 1){
            dp[i] = tmp[i];
        }

    }

    int res = -LNF;
    FOR(i, 0, 50*MAX, 1){
        res = max(res, dp[i]);
    }

    cout<<res<<'\n';

    return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1868 KB Output is correct
2 Correct 2 ms 1868 KB Output is correct
3 Correct 17 ms 1988 KB Output is correct
4 Correct 32 ms 1976 KB Output is correct
5 Correct 275 ms 2124 KB Output is correct
6 Correct 277 ms 2124 KB Output is correct
7 Correct 292 ms 2124 KB Output is correct
8 Correct 291 ms 2152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1868 KB Output is correct
2 Correct 3 ms 1868 KB Output is correct
3 Correct 17 ms 1988 KB Output is correct
4 Correct 17 ms 1868 KB Output is correct
5 Correct 138 ms 2048 KB Output is correct
6 Correct 132 ms 1996 KB Output is correct
7 Correct 296 ms 2136 KB Output is correct
8 Correct 295 ms 2124 KB Output is correct
9 Correct 282 ms 2244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1868 KB Output is correct
2 Correct 7 ms 1868 KB Output is correct
3 Correct 27 ms 1996 KB Output is correct
4 Correct 29 ms 2000 KB Output is correct
5 Correct 57 ms 2016 KB Output is correct
6 Correct 56 ms 2008 KB Output is correct
7 Correct 73 ms 2004 KB Output is correct
8 Correct 73 ms 1996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1868 KB Output is correct
2 Correct 4 ms 1972 KB Output is correct
3 Correct 216 ms 2096 KB Output is correct
4 Correct 285 ms 2140 KB Output is correct
5 Correct 547 ms 2252 KB Output is correct
6 Correct 584 ms 2356 KB Output is correct
7 Correct 573 ms 2364 KB Output is correct
8 Correct 567 ms 2360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1868 KB Output is correct
2 Correct 24 ms 1996 KB Output is correct
3 Correct 119 ms 2036 KB Output is correct
4 Correct 294 ms 2124 KB Output is correct
5 Correct 578 ms 2372 KB Output is correct
6 Correct 577 ms 2304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1868 KB Output is correct
2 Correct 2 ms 1868 KB Output is correct
3 Correct 17 ms 1988 KB Output is correct
4 Correct 32 ms 1976 KB Output is correct
5 Correct 275 ms 2124 KB Output is correct
6 Correct 277 ms 2124 KB Output is correct
7 Correct 292 ms 2124 KB Output is correct
8 Correct 291 ms 2152 KB Output is correct
9 Correct 2 ms 1868 KB Output is correct
10 Correct 3 ms 1868 KB Output is correct
11 Correct 17 ms 1988 KB Output is correct
12 Correct 17 ms 1868 KB Output is correct
13 Correct 138 ms 2048 KB Output is correct
14 Correct 132 ms 1996 KB Output is correct
15 Correct 296 ms 2136 KB Output is correct
16 Correct 295 ms 2124 KB Output is correct
17 Correct 282 ms 2244 KB Output is correct
18 Correct 6 ms 1868 KB Output is correct
19 Correct 7 ms 1868 KB Output is correct
20 Correct 27 ms 1996 KB Output is correct
21 Correct 29 ms 2000 KB Output is correct
22 Correct 57 ms 2016 KB Output is correct
23 Correct 56 ms 2008 KB Output is correct
24 Correct 73 ms 2004 KB Output is correct
25 Correct 73 ms 1996 KB Output is correct
26 Correct 4 ms 1868 KB Output is correct
27 Correct 4 ms 1972 KB Output is correct
28 Correct 216 ms 2096 KB Output is correct
29 Correct 285 ms 2140 KB Output is correct
30 Correct 547 ms 2252 KB Output is correct
31 Correct 584 ms 2356 KB Output is correct
32 Correct 573 ms 2364 KB Output is correct
33 Correct 567 ms 2360 KB Output is correct
34 Correct 2 ms 1868 KB Output is correct
35 Correct 24 ms 1996 KB Output is correct
36 Correct 119 ms 2036 KB Output is correct
37 Correct 294 ms 2124 KB Output is correct
38 Correct 578 ms 2372 KB Output is correct
39 Correct 577 ms 2304 KB Output is correct
40 Correct 150 ms 1996 KB Output is correct
41 Correct 276 ms 2124 KB Output is correct
42 Correct 433 ms 2372 KB Output is correct
43 Correct 585 ms 2368 KB Output is correct
44 Correct 583 ms 2380 KB Output is correct
45 Correct 588 ms 2500 KB Output is correct
46 Correct 297 ms 2160 KB Output is correct
47 Correct 428 ms 2264 KB Output is correct
48 Correct 429 ms 2260 KB Output is correct