# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1174913 | Dan4Life | Cloud Computing (CEOI18_clo) | C++20 | 236 ms | 1552 KiB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(a) begin(a),end(a)
using ll = long long;
using ar4 = array<ll,4>;
const int mxM = 100001;
ll dp[mxM];
vector<ar4> a;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
for(int t:{0,1}){
int n,c,f,v; cin >> n;
while(n--) cin>>c>>f>>v, a.pb({c,f,v*(t?1:-1),t});
}
sort(all(a),[&](ar4 x, ar4 y){
if(x[1]!=y[1]) return x[1]>y[1];
return x[3]<y[3];
});
fill(dp+1,dp+mxM,-2e18);
for(auto [c,f,v,t] : a){
if(!t){
for(int j = mxM-1; j>=c; j--)
dp[j] = max(dp[j], dp[j-c]+v);
}
else{
for(int j = 0; j+c<mxM; j++)
dp[j] = max(dp[j], dp[j+c]+v);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |