# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
229626 | Ruxandra985 | Cloud Computing (CEOI18_clo) | C++14 | 407 ms | 1400 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 <bits/stdc++.h>
#define INF 2000000000000000000
using namespace std;
struct informatie{
int proc , rate , cost;
} v[4010];
int cmp (informatie x , informatie y){
if (x.rate != y.rate)
return x.rate > y.rate;
else if (x.cost != y.cost)
return x.cost < y.cost;
else return x.proc < y.proc;
}
long long dp[50 * 2000 + 10];
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , i , m , elem , proc , cost , j;
long long sol;
fscanf (fin,"%d",&n);
for (i = 1 ; i <= n ; i++){ /// ofertele
fscanf (fin,"%d%d%d",&v[i].proc , &v[i].rate , &v[i].cost);
v[i].cost = -v[i].cost;
}
fscanf (fin,"%d",&m);
for (i = 1 ; i <= m ; i++){ /// cererile
fscanf (fin,"%d%d%d",&v[n + i].proc , &v[n + i].rate , &v[n + i].cost);
v[n + i].proc = -v[n + i].proc;
}
/// cand cumperi un calculator, irosesti niste bani si acumulezi niste procesoare
/// cand satisfaci o cerere, acumulezi niste bani si consumi niste procesoare
elem = n + m;
sort (v + 1 , v + elem + 1 , cmp); /// sort descresc dupa rate
/// la fiecare pas trb sa ai PROCESOARE VALABILE >= 0
for (i = 0 ; i <= 50 * 2000 ; i++){
dp[i] = -INF;
}
dp[0] = 0;
for (i = 1 ; i <= elem ; i++){
proc = v[i].proc;
cost = v[i].cost;
if (proc >= 0){ /// adaugi ceva
for (j = 50 * 2000 - proc ; j >= 0 ; j--)
dp[j + proc] = max(dp[j + proc] , dp[j] + cost);
}
else {
for (j = -proc ; j <= 2000 * 50 ; j++)
dp[j + proc] = max(dp[j + proc] , dp[j] + cost);
}
}
sol = 0;
for (i = 0 ; i <= 2000 * 50 ; i++)
sol = max(sol , dp[i]);
fprintf (fout,"%lld",sol);
return 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... |