Submission #132614

#TimeUsernameProblemLanguageResultExecution timeMemory
132614alexpetrescuCloud Computing (CEOI18_clo)C++14
100 / 100
303 ms1400 KiB
#include <cstdio> #include <algorithm> #include <vector> //FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w"); #define fin stdin #define fout stdout struct myc { int c, f, v, t; inline bool operator < (const myc &u) const { if (f != u.f) return f < u.f; else return t > u.t; } }; long long d[100009]; inline void _(long long &a, long long b) { a = std::max(a, b); } int main() { int calc; fscanf(fin, "%d", &calc); std::vector < myc > v; for (; calc; calc--) { int c, f, V; fscanf(fin, "%d%d%d", &c, &f, &V); v.push_back({c, f, V, 0}); } int coma; fscanf(fin, "%d", &coma); for (; coma; coma--) { int c, f, V; fscanf(fin, "%d%d%d", &c, &f, &V); v.push_back({c, f, V, 1}); } std::sort(v.begin(), v.end()); int sumC = 0; for (auto &x : v) { if (x.t) { for (int i = sumC; i >= 0; i--) _(d[i + x.c], d[i] + x.v); sumC += x.c; } else { for (int i = 1; i < x.c; i++) _(d[0], d[i] - x.v); for (int i = x.c; i <= sumC; i++) _(d[i - x.c], d[i] - x.v); } } fprintf(fout, "%lld\n", d[0]); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:25:11: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf(fin, "%d", &calc);
     ~~~~~~^~~~~~~~~~~~~~~~~~
clo.cpp:30:15: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf(fin, "%d%d%d", &c, &f, &V);
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:36:11: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf(fin, "%d", &coma);
     ~~~~~~^~~~~~~~~~~~~~~~~~
clo.cpp:40:15: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf(fin, "%d%d%d", &c, &f, &V);
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...