# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134141 | dragonslayerit | Cloud Computing (CEOI18_clo) | C++14 | 393 ms | 1280 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>
const long long INF=1e15+7;
struct Event{
enum{
TYPE_COMPUTER=1,
TYPE_CUSTOMER=2,
}type;
int C,F,V;
void read(){
scanf("%d %d %d",&C,&F,&V);
}
bool operator<(Event e)const{
if(F!=e.F) return F>e.F;
return type<e.type;
}
}events[4000];
long long profit[100001];
void setmax(long long& x,long long y){
x=std::max(x,y);
}
int main(){
int N;
scanf("%d",&N);
for(int i=0;i<N;i++){
events[i].read();
events[i].type=Event::TYPE_COMPUTER;
}
int M;
scanf("%d",&M);
for(int i=0;i<M;i++){
events[N+i].read();
events[N+i].type=Event::TYPE_CUSTOMER;
}
std::sort(events,events+N+M);
std::fill(profit+1,profit+100001,-INF);
for(int i=0;i<N+M;i++){
switch(events[i].type){
case Event::TYPE_CUSTOMER:
for(int x=events[i].C;x<=100000;x++){
setmax(profit[x-events[i].C],profit[x]+events[i].V);
}
break;
case Event::TYPE_COMPUTER:
for(int x=100000;x>=events[i].C;x--){
setmax(profit[x],profit[x-events[i].C]-events[i].V);
}
break;
}
/*
for(int x=0;x<=100000;x++){
if(profit[x]>-INF/2){
printf("%d: %lld\n",x,profit[x]);
}
}
*/
}
printf("%lld\n",*std::max_element(profit,profit+100001));
}
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... |