Submission #953006

# Submission time Handle Problem Language Result Execution time Memory
953006 2024-03-25T10:05:33 Z BF001 Cloud Computing (CEOI18_clo) C++17
0 / 100
3 ms 856 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define M 100005
#define N 40005
#define oo 1e18

struct ii{
	int typ, c, f, v;
	bool operator < (ii o){
		if (f == o.f) return typ == 1;
		return f > o.f;
	}
} a[N];

int n, m, ma, dp[M];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
        
    cin >> n;
    for (int i = 1; i <= n; i++){
    	cin >> a[i].c >> a[i].f >> a[i].v;
    	a[i].typ = 1;
    	ma += a[i].c;
    }
    cin >> m;
    for (int i = n + 1; i <= n + m; i++){
    	cin >> a[i].c >> a[i].f >> a[i].v;
    	a[i].typ = 2;
    }

    n += m;
    for (int i = 0; i <= ma; i++) dp[i] = -oo;
    dp[0] = 0;
	ma = N - 1;
    sort(a + 1, a + n + 1);
    int res = 0;

    for (int i = 1; i <= n; i++){
    	if (a[i].typ == 1){
    		for (int j = ma; j >= 0; j--){
    			if (j  < a[i].c) break;
    			if (dp[j - a[i].c] == -oo) continue;
    			dp[j] = max(dp[j], dp[j - a[i].c] - a[i].v);
    			res = max(res, dp[j]);
    		}
    		continue;
    	}
    	for (int j = 0; j <= ma; j++){
    		if (j + a[i].c > ma) break;
    		if (dp[j + a[i].c] == -oo) continue;
    		dp[j] = max(dp[j], dp[j + a[i].c] + a[i].v);
    		res = max(res, dp[j]);
    	}
    }

    cout << res;

    return 0;
}     
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -