# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502187 | RambaXGorilla | Cloud Computing (CEOI18_clo) | C++17 | 715 ms | 2184 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
#include<algorithm>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
int N, M;
vector <int> comps[4010];
ll curr[100001];
ll next_[100001] = {};
int main(){
scanf("%d",&N);
for(int i = 0;i < N;i++){
comps[i] = vector <int> (4);
scanf("%d%d%d",&comps[i][2],&comps[i][0],&comps[i][3]);
comps[i][1] = 1;
}
scanf("%d",&M);
for(int i = N;i < N + M;i++){
comps[i] = vector <int> (4);
scanf("%d%d%d",&comps[i][2],&comps[i][0],&comps[i][3]);
comps[i][1] = 0;
}
sort(comps, comps + N + M, greater <vector <int>> ());
for(int i = N + M - 1;i > -1;i--){
for(int j = 0;j < 100001;j++){
if(comps[i][1]){
curr[j] = max(next_[j], next_[min(comps[i][2] + j, 100000)] - comps[i][3]);
}
else{
curr[j] = next_[j];
if(j >= comps[i][2]){
curr[j] = max(curr[j], next_[j - comps[i][2]] + comps[i][3]);
}
}
}
copy(curr, curr + 100001, next_);
}
printf("%lld",curr[0]);
}
Compilation message (stderr)
# | 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... |