Submission #335393

#TimeUsernameProblemLanguageResultExecution timeMemory
335393parsabahramiCloud Computing (CEOI18_clo)C++17
100 / 100
306 ms8428 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 1e6 + 10, MOD = 1e9 + 7; ll n, m, k, dp[N], sum = 0; pair<int, pii> A[N]; int main() { scanf("%lld", &n); for (int i = 1; i <= n; i++) { int c, f, v; scanf("%d%d%d", &c, &f, &v); A[i] = {f, {c, v}}; } scanf("%lld", &m); for (int i = 1; i <= m; i++) { int c, f, v; scanf("%d%d%d", &c, &f, &v); A[i + n] = {f, {-c, v}}; } sort(A + 1, A + n + m + 1); fill(dp + 1, dp + N, -1e18); for (int i = n + m; i >= 1; i--) { pii X = A[i].S; int c = abs(X.F), v = X.S; if (X.F > 0) { for (int j = sum; j >= 0; j--) { dp[j + c] = max(dp[j + c], dp[j] - v); } sum += c; } else { for (int j = c; j <= sum; j++) { dp[j - c] = max(dp[j - c], dp[j] + v); } } } printf("%lld\n", *max_element(dp, dp + N)); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~
clo.cpp:18:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         int c, f, v; scanf("%d%d%d", &c, &f, &v);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
clo.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |     scanf("%lld", &m);
      |     ~~~~~^~~~~~~~~~~~
clo.cpp:23:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |         int c, f, v; scanf("%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...