Submission #229626

#TimeUsernameProblemLanguageResultExecution timeMemory
229626Ruxandra985Cloud Computing (CEOI18_clo)C++14
100 / 100
407 ms1400 KiB
#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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...