Submission #522071

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5220712022-02-03 18:06:49LucaDantasCloud Computing (CEOI18_clo)C++17
100 / 100
1057 ms1960 KiB
#include <cstdio>
#include <algorithm>
#include <cstring>
constexpr int maxn = 2010;
constexpr int maxn2 = 100010;
constexpr long long inf = 0x3f3f3f3f3f3f3f3f;
struct Order { int c, f, v; bool operator<(Order o) const { if(f != o.f) return f < o.f; return c > o.c; } };
Order td[maxn<<1];
long long dp[2][maxn2];
void max_self(long long& a, long long b) { a = std::max(a, b); }
int main() {
int n; scanf("%d", &n);
for(int i = 0, c, f, v; i < n; i++)
scanf("%d %d %d", &c, &f, &v), td[i] = {-c, f, -v};
int m, sum = 0; scanf("%d", &m);
for(int i = n, c, f, v; i < n+m; i++)
scanf("%d %d %d", &c, &f, &v), td[i] = {c, f, v}, sum += c;
std::sort(td, td+n+m);
for(int i = 0; i < 2; i++)
for(int j = 0; j < maxn2; j++)
dp[i][j] = -inf;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:37:18: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   37 |     max_self(dp[i&1^1][std::max(0, abertas + td[i].c)], dp[i&1][abertas] + td[i].v),
      |                 ~^~
clo.cpp:38:18: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   38 |     max_self(dp[i&1^1][abertas], dp[i&1][abertas]);
      |                 ~^~
clo.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  int n; scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
clo.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d %d %d", &c, &f, &v), td[i] = {-c, f, -v};
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:22:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  int m, sum = 0; scanf("%d", &m);
      |                  ~~~~~^~~~~~~~~~
clo.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%d %d %d", &c, &f, &v), td[i] = {c, f, v}, sum += c;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...