Submission #997383

#TimeUsernameProblemLanguageResultExecution timeMemory
997383daffuwuCloud Computing (CEOI18_clo)C++14
72 / 100
409 ms2140 KiB
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

long long n, m, dp[2][100069]; //{komp sekarang, order sekarang, core tersisa komp, needed core order}

struct machine
{
    long long c, f, v;
    bool operator<(const machine other) const
    {
        return f<other.f;
    }
} a[4069];

int main() 
{
    long long i, j;
    scanf("%lld", &n);
    for (i=1; i<=n; i++)
    {
        scanf("%lld%lld%lld", &a[i].c, &a[i].f, &a[i].v);
        a[i].c *= -1;
        a[i].v *= -1;
    }
    scanf("%lld", &m);
    for (i=1; i<=m; i++)
    {
        scanf("%lld%lld%lld", &a[n+i].c, &a[n+i].f, &a[n+i].v);
    }
    sort(a+1, a+n+m+1);
    //dp[i][j] --> max uang kalau total core adalah j
    for (j=1; j<=100000; j++) dp[(n+m+1)%2][j] = -1e15; 
    for (i=n+m; i>=1; i--)
    {
        for (j=0; j<=100000; j++)
        {
            dp[i%2][j] = dp[(i+1)%2][j];
            if (j+a[i].c<=100000) dp[i%2][j] = max(dp[i%2][j], dp[(i+1)%2][max(0ll, j+a[i].c)]+a[i].v);
        }
    }
    printf("%lld\n", dp[1][0]);
}

Compilation message (stderr)

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