Submission #578914

# Submission time Handle Problem Language Result Execution time Memory
578914 2022-06-18T07:45:21 Z mousebeaver Two Dishes (JOI19_dishes) C++14
10 / 100
650 ms 1048576 KB
#define ll long long
#define ull unsigned ll
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin>>n>>m;
    vector<ll> a(n);
    vector<ll> s(n);
    vector<ll> p(n);
    for(int i = 0; i < n; i++)
    {
        cin>>a[i]>>s[i]>>p[i];
    }
    vector<ll> b(m);
    vector<ll> t(m);
    vector<ll> q(m);
    for(int i = 0; i < m; i++)
    {
        cin>>b[i]>>t[i]>>q[i];
    }

    vector<ll> prea(n);
    prea[0] = a[0];
    for(int i = 1; i < n; i++)
    {
        prea[i] = prea[i-1]+a[i];
    }
    vector<ll> preb(m);
    preb[0] = b[0];
    for(int i = 1; i < m; i++)
    {
        preb[i] = preb[i-1]+b[i];
    }

    vector<vector<ll>> dp(n+1, vector<ll> (m+1, 0));
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            ll time = 0;
            if(i > 0)
            {
                time += prea[i-1];
            }
            if(j > 0)
            {
                time += preb[j-1];
            }

            //Dish 1:
            if(i > 0)
            {
                ll score = dp[i-1][j];
                if(time <= s[i-1])
                {
                    score += p[i-1];
                }
                dp[i][j] = max(dp[i][j], score);
            }
            if(j > 0)
            {
                ll score = dp[i][j-1];
                if(time <= t[j-1])
                {
                    score += q[j-1];
                }
                dp[i][j] = max(dp[i][j], score);
            }
        }
    }

    cout<<dp[n][m]<<"\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 650 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 320 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 320 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 57 ms 31924 KB Output is correct
18 Correct 42 ms 31948 KB Output is correct
19 Correct 55 ms 31948 KB Output is correct
20 Correct 46 ms 29656 KB Output is correct
21 Correct 49 ms 30752 KB Output is correct
22 Correct 49 ms 31900 KB Output is correct
23 Correct 49 ms 31884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 320 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 57 ms 31924 KB Output is correct
18 Correct 42 ms 31948 KB Output is correct
19 Correct 55 ms 31948 KB Output is correct
20 Correct 46 ms 29656 KB Output is correct
21 Correct 49 ms 30752 KB Output is correct
22 Correct 49 ms 31900 KB Output is correct
23 Correct 49 ms 31884 KB Output is correct
24 Runtime error 607 ms 1048576 KB Execution killed with signal 9
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 320 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 57 ms 31924 KB Output is correct
18 Correct 42 ms 31948 KB Output is correct
19 Correct 55 ms 31948 KB Output is correct
20 Correct 46 ms 29656 KB Output is correct
21 Correct 49 ms 30752 KB Output is correct
22 Correct 49 ms 31900 KB Output is correct
23 Correct 49 ms 31884 KB Output is correct
24 Runtime error 607 ms 1048576 KB Execution killed with signal 9
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 320 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 57 ms 31924 KB Output is correct
18 Correct 42 ms 31948 KB Output is correct
19 Correct 55 ms 31948 KB Output is correct
20 Correct 46 ms 29656 KB Output is correct
21 Correct 49 ms 30752 KB Output is correct
22 Correct 49 ms 31900 KB Output is correct
23 Correct 49 ms 31884 KB Output is correct
24 Runtime error 607 ms 1048576 KB Execution killed with signal 9
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 650 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 650 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -