Submission #927290

# Submission time Handle Problem Language Result Execution time Memory
927290 2024-02-14T15:49:15 Z boris_mihov Two Dishes (JOI19_dishes) C++17
10 / 100
56 ms 36396 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>

typedef long long llong;
const int MAXN = 2000 + 10;
const llong INF = 1e18;

int n, m;
struct Dish
{
    int time;
    llong limit;
    int reward;
};

Dish a[MAXN];
Dish b[MAXN];
llong dp[MAXN][MAXN];
bool bl[MAXN][MAXN];

llong f(int aPos, int bPos, llong sum)
{
    if (aPos == n + 1 && bPos == m + 1)
    {
        return 0;
    }

    if (bl[aPos][bPos])
    {
        return dp[aPos][bPos];
    }

    bl[aPos][bPos] = true;
    dp[aPos][bPos] = -INF;

    if (aPos <= n)
    {
        dp[aPos][bPos] = std::max(dp[aPos][bPos], f(aPos + 1, bPos, sum + a[aPos].time) + (sum + a[aPos].time <= a[aPos].limit ? a[aPos].reward : 0));
    }

    if (bPos <= m)
    {
        dp[aPos][bPos] = std::max(dp[aPos][bPos], f(aPos, bPos + 1, sum + b[bPos].time) + (sum + b[bPos].time <= b[bPos].limit ? b[bPos].reward : 0));
    }

    return dp[aPos][bPos];
}

void solve()
{
    std::cout << f(1, 1, 0) << '\n';
}

void input()
{
    std::cin >> n >> m;
    for (int i = 1 ; i <= n ; ++i)
    {
        std::cin >> a[i].time >> a[i].limit >> a[i].reward;
    }

    for (int i = 1 ; i <= m ; ++i)
    {
        std::cin >> b[i].time >> b[i].limit >> b[i].reward;
    }
}

void fastIOI()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

int main()
{
    fastIOI();
    input();
    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2512 KB Output is correct
17 Correct 56 ms 36188 KB Output is correct
18 Correct 49 ms 36396 KB Output is correct
19 Correct 49 ms 36188 KB Output is correct
20 Correct 45 ms 36188 KB Output is correct
21 Correct 50 ms 35928 KB Output is correct
22 Correct 51 ms 36332 KB Output is correct
23 Correct 50 ms 36332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2512 KB Output is correct
17 Correct 56 ms 36188 KB Output is correct
18 Correct 49 ms 36396 KB Output is correct
19 Correct 49 ms 36188 KB Output is correct
20 Correct 45 ms 36188 KB Output is correct
21 Correct 50 ms 35928 KB Output is correct
22 Correct 51 ms 36332 KB Output is correct
23 Correct 50 ms 36332 KB Output is correct
24 Runtime error 3 ms 736 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2512 KB Output is correct
17 Correct 56 ms 36188 KB Output is correct
18 Correct 49 ms 36396 KB Output is correct
19 Correct 49 ms 36188 KB Output is correct
20 Correct 45 ms 36188 KB Output is correct
21 Correct 50 ms 35928 KB Output is correct
22 Correct 51 ms 36332 KB Output is correct
23 Correct 50 ms 36332 KB Output is correct
24 Runtime error 3 ms 736 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2512 KB Output is correct
17 Correct 56 ms 36188 KB Output is correct
18 Correct 49 ms 36396 KB Output is correct
19 Correct 49 ms 36188 KB Output is correct
20 Correct 45 ms 36188 KB Output is correct
21 Correct 50 ms 35928 KB Output is correct
22 Correct 51 ms 36332 KB Output is correct
23 Correct 50 ms 36332 KB Output is correct
24 Runtime error 3 ms 736 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -