Submission #229624

# Submission time Handle Problem Language Result Execution time Memory
229624 2020-05-05T13:15:15 Z Ruxandra985 Cloud Computing (CEOI18_clo) C++14
18 / 100
412 ms 1280 KB
#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 = 1 ; i <= 2000 * 50 ; i++)
        sol = max(sol , dp[i]);

    fprintf (fout,"%lld",sol);
    return 0;
}

Compilation message

clo.cpp: In function 'int main()':
clo.cpp:27:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&n);
     ~~~~~~~^~~~~~~~~~~~~
clo.cpp:30:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d%d%d",&v[i].proc , &v[i].rate , &v[i].cost);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:35:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&m);
     ~~~~~~~^~~~~~~~~~~~~
clo.cpp:38:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d%d%d",&v[n + i].proc , &v[n + i].rate , &v[n + i].cost);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1152 KB Output is correct
2 Correct 5 ms 1152 KB Output is correct
3 Incorrect 16 ms 1152 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1152 KB Output is correct
2 Correct 6 ms 1152 KB Output is correct
3 Correct 16 ms 1280 KB Output is correct
4 Incorrect 15 ms 1152 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1152 KB Output is correct
2 Incorrect 7 ms 1152 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1152 KB Output is correct
2 Correct 21 ms 1152 KB Output is correct
3 Correct 83 ms 1152 KB Output is correct
4 Correct 203 ms 1272 KB Output is correct
5 Correct 390 ms 1152 KB Output is correct
6 Correct 412 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1152 KB Output is correct
2 Correct 5 ms 1152 KB Output is correct
3 Incorrect 16 ms 1152 KB Output isn't correct
4 Halted 0 ms 0 KB -