Submission #364349

# Submission time Handle Problem Language Result Execution time Memory
364349 2021-02-09T02:34:01 Z Killer2501 Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
1 ms 492 KB
#include <bits/stdc++.h>
#define pb push_back
#define task "sequence"
#define pll pair<ll, ll>
#define pii pair<vector<ll>, ll>
#define fi first
#define se second

using ll = long long;
const long long mod = 1e15+7;
const ll mod1 = 1e9+1;
const ll N = 205;
const int base = 350;
using ull = unsigned long long;
using namespace std;
string s, ss;
ll n, m, t, k, T, cnt, tong, a[N], c[N], b[N], dp[N][N][N][2];
vector<ll> adj[N], kq;
pll p[N];
int ans;
void Min(ll& x, ll y)
{
    if(x > y)x = y;
}
void sol()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        b[i] = m - a[i];
        //cout << b[i] <<" ";
    }
    for(int i = 1; i <= n; i ++)b[i] = m - a[n-i+1];
    //cout << '\n';
    c[0] = c[n+1] = -1;
    for(int i = 1; i <= n; i ++)cin >> c[i];
    for(int i = 0; i <= n; i ++)
        for(int j = 0; j <= n; j ++)
            for(int l = 0; l <= n; l ++)dp[i][j][l][0] = dp[i][j][l][1] = mod;
    dp[0][0][0][0] = dp[0][0][0][1] = 0;
    for(int i = 0; i <= n; i ++)
    {
        for(int j = 0; j <= n; j ++)
        {
            for(int l = 0; l <= n; l ++)
            {
                if(dp[i][j][l][0] != mod)
                {
                    ans = max(ans, l);
                    if(i < n)
                    {
                        k = dp[i][j][l][0] + a[i+1] - a[i];
                        Min(dp[i+1][j][l+(k<=c[i+1])][0], k);
                    }
                    if(j < n)
                    {
                        k = dp[i][j][l][0] + b[j+1] + a[i];
                        Min(dp[i][j+1][l+(k<=c[n-j])][1], k);
                    }
                }
                if(dp[i][j][l][1] != mod)
                {
                    ans = max(ans, l);
                    if(i < n)
                    {
                        k = dp[i][j][l][1] + b[j] + a[i+1];
                        Min(dp[i+1][j][l+(k<=c[i+1])][0], k);
                    }
                    if(j < n)
                    {
                        k = dp[i][j][l][1] + b[j+1] - b[j];
                        Min(dp[i][j+1][l+(k<=c[n-j])][1], k);
                    }

                }
                cout << i <<" "<<j<<" "<<l<<" "<<dp[i][j][l][0]<<" "<<dp[i][j][l][1] << '\n';
            }
        }
    }
    cout << ans;
}

int main()
{
    if(fopen(task".in", "r")){
       freopen(task".in", "r", stdin);
       freopen(task".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest;
    ntest =  1;
    //cin >> ntest;
    //cout << (1<<30) << '\n';
    while(ntest -- > 0)
    sol();

}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:87:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   87 |        freopen(task".in", "r", stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ho_t3.cpp:88:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   88 |        freopen(task".out", "w", stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -