Submission #1115588

# Submission time Handle Problem Language Result Execution time Memory
1115588 2024-11-20T16:36:03 Z staszic_ojuz Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
2000 ms 128064 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr ll INF = 1e13 + 7;
constexpr int MAXN = 211;
ll dp[MAXN][MAXN][MAXN][2];

int main()
{
    int n, p;
    cin >> n >> p;
    vector<int> r;
    vector<int> l;
    vector<int> t;
    r.push_back(0);
    r.push_back(0);
    l.push_back(0);
    l.push_back(0);
    t.push_back(0);
    for(int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        r.push_back(a);
    }
    for(int i = n+1; i >= 2; --i)
        l.push_back(p-r[i]);
    for(int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        t.push_back(a);
    }
    t.push_back(0);
    for(int i = 0; i <= n+1; ++i)
    {
        for(int j = 0; j <= n+1; ++j)
        {
            for(int k = 0; k <= n; ++k)
            {
                dp[i][j][k][0] = INF;
                dp[i][j][k][1] = INF;
            }
        }
    }
    dp[1][1][0][0] = 0;
    dp[1][1][0][1] = 0;
    dp[0][1][0][0] = 0;
    dp[0][1][0][1] = 0;
    dp[1][0][0][0] = 0;
    dp[1][0][0][1] = 0;
    for(int i = 1; i <= n+1; ++i)
    {
        for(int j = 1; j <= n+1; ++j)
        {
            if(j+i > n+2)
                continue;
            for(int k = 0; k <= (i == 1 && j == 1 ? 0 : n); ++k)
            {
                if(k > 0)
                    dp[i][j][k][0] = min(dp[i-1][j][k-1][0] + l[i]-l[i-1], dp[i-1][j][k-1][1] + l[i]+r[j]);
                if(dp[i][j][k][0] > t[n-i+2])
                    dp[i][j][k][0] = min(dp[i-1][j][k][0] + l[i]-l[i-1], dp[i-1][j][k][1] + l[i]+r[j]);
                dp[i][j][k][0] = min(dp[i][j][k][0], INF);

                if(k > 0)
                    dp[i][j][k][1] = min(dp[i][j-1][k-1][1] + r[j]-r[j-1], dp[i][j-1][k-1][0] + l[i]+r[j]);
                if(dp[i][j][k][1] > t[j-1])
                    dp[i][j][k][1] = min(dp[i][j-1][k][1] + r[j]-r[j-1], dp[i][j-1][k][0] + l[i]+r[j]);
                dp[i][j][k][1] = min(dp[i][j][k][1], INF);

                cerr << i << " " << j << " " << k << ": " << dp[i][j][k][0] << " " << dp[i][j][k][1] << "\n";
            }
        }
    }
    int odp = 0;
    for(int i = 1; i <= n+1; ++i)
    {
        for(int j = 1; j <= n+1; ++j)
        {
            for(int k = 1; k <= n; ++k)
            {
                for(int zj = 0; zj < 2; ++zj)
                {   
                    if(dp[i][j][k][zj] < INF)
                        odp = max(odp, k);
                }
            }
        }
    }
    cout << odp;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4432 KB Output is correct
2 Correct 3 ms 4432 KB Output is correct
3 Correct 9 ms 8700 KB Output is correct
4 Correct 4 ms 6628 KB Output is correct
5 Correct 5 ms 6480 KB Output is correct
6 Correct 18 ms 10576 KB Output is correct
7 Correct 7 ms 6480 KB Output is correct
8 Correct 14 ms 8528 KB Output is correct
9 Correct 18 ms 10576 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 18 ms 10576 KB Output is correct
13 Correct 18 ms 10576 KB Output is correct
14 Correct 5 ms 6480 KB Output is correct
15 Correct 7 ms 6480 KB Output is correct
16 Correct 17 ms 10576 KB Output is correct
17 Correct 18 ms 10748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4432 KB Output is correct
2 Correct 3 ms 4432 KB Output is correct
3 Correct 9 ms 8700 KB Output is correct
4 Correct 4 ms 6628 KB Output is correct
5 Correct 5 ms 6480 KB Output is correct
6 Correct 18 ms 10576 KB Output is correct
7 Correct 7 ms 6480 KB Output is correct
8 Correct 14 ms 8528 KB Output is correct
9 Correct 18 ms 10576 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 18 ms 10576 KB Output is correct
13 Correct 18 ms 10576 KB Output is correct
14 Correct 5 ms 6480 KB Output is correct
15 Correct 7 ms 6480 KB Output is correct
16 Correct 17 ms 10576 KB Output is correct
17 Correct 18 ms 10748 KB Output is correct
18 Correct 28 ms 12792 KB Output is correct
19 Correct 11 ms 8528 KB Output is correct
20 Correct 18 ms 10576 KB Output is correct
21 Correct 33 ms 12624 KB Output is correct
22 Correct 10 ms 8692 KB Output is correct
23 Correct 32 ms 12860 KB Output is correct
24 Correct 22 ms 10576 KB Output is correct
25 Correct 31 ms 12624 KB Output is correct
26 Correct 27 ms 12624 KB Output is correct
27 Correct 7 ms 6480 KB Output is correct
28 Correct 9 ms 8528 KB Output is correct
29 Correct 32 ms 12864 KB Output is correct
30 Correct 31 ms 12872 KB Output is correct
31 Correct 27 ms 12624 KB Output is correct
32 Correct 21 ms 10576 KB Output is correct
33 Correct 31 ms 12844 KB Output is correct
34 Correct 31 ms 12796 KB Output is correct
35 Correct 31 ms 12624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4432 KB Output is correct
2 Correct 3 ms 4432 KB Output is correct
3 Correct 9 ms 8700 KB Output is correct
4 Correct 4 ms 6628 KB Output is correct
5 Correct 5 ms 6480 KB Output is correct
6 Correct 18 ms 10576 KB Output is correct
7 Correct 7 ms 6480 KB Output is correct
8 Correct 14 ms 8528 KB Output is correct
9 Correct 18 ms 10576 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 18 ms 10576 KB Output is correct
13 Correct 18 ms 10576 KB Output is correct
14 Correct 5 ms 6480 KB Output is correct
15 Correct 7 ms 6480 KB Output is correct
16 Correct 17 ms 10576 KB Output is correct
17 Correct 18 ms 10748 KB Output is correct
18 Execution timed out 2056 ms 128064 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4432 KB Output is correct
2 Correct 3 ms 4432 KB Output is correct
3 Correct 9 ms 8700 KB Output is correct
4 Correct 4 ms 6628 KB Output is correct
5 Correct 5 ms 6480 KB Output is correct
6 Correct 18 ms 10576 KB Output is correct
7 Correct 7 ms 6480 KB Output is correct
8 Correct 14 ms 8528 KB Output is correct
9 Correct 18 ms 10576 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 18 ms 10576 KB Output is correct
13 Correct 18 ms 10576 KB Output is correct
14 Correct 5 ms 6480 KB Output is correct
15 Correct 7 ms 6480 KB Output is correct
16 Correct 17 ms 10576 KB Output is correct
17 Correct 18 ms 10748 KB Output is correct
18 Correct 28 ms 12792 KB Output is correct
19 Correct 11 ms 8528 KB Output is correct
20 Correct 18 ms 10576 KB Output is correct
21 Correct 33 ms 12624 KB Output is correct
22 Correct 10 ms 8692 KB Output is correct
23 Correct 32 ms 12860 KB Output is correct
24 Correct 22 ms 10576 KB Output is correct
25 Correct 31 ms 12624 KB Output is correct
26 Correct 27 ms 12624 KB Output is correct
27 Correct 7 ms 6480 KB Output is correct
28 Correct 9 ms 8528 KB Output is correct
29 Correct 32 ms 12864 KB Output is correct
30 Correct 31 ms 12872 KB Output is correct
31 Correct 27 ms 12624 KB Output is correct
32 Correct 21 ms 10576 KB Output is correct
33 Correct 31 ms 12844 KB Output is correct
34 Correct 31 ms 12796 KB Output is correct
35 Correct 31 ms 12624 KB Output is correct
36 Execution timed out 2056 ms 128064 KB Time limit exceeded
37 Halted 0 ms 0 KB -