QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#816493#2500. Collecting Stamps 3sichengzhou0 4ms148264kbC++171.5kb2024-12-16 12:48:492024-12-16 12:48:49

Judging History

你现在查看的是最新测评结果

  • [2024-12-16 12:48:49]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:148264kb
  • [2024-12-16 12:48:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=210;
int n,m;
int a[N],b[N];
typedef long long LL;
LL f[N][N][N][2];
#define mn(x,y) x=min(x,y)
#define L m
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    a[n+1]=L;
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    memset(f,0x3f,sizeof(f));
    f[0][0][0][0]=0;
    int ans=0;
    for(int len=0;len<n;len++)
    {
        for(int i=0;i<=len;i++)
        {
            int j=len-i;
            for(int k=0;k<=len;k++)
            {
                LL x=f[i][j][k][0];
                if(x<=1e9)
                {
                //    cout<<i<<' '<<j<<' '<<k<<" 0\n";
                //    cout<<x<<endl;
                    ans=max(ans,k);
                bool c=(b[(n+1-(i+1))]>=x+a[n+1-i]-a[n+1-(i+1)]);
                mn(f[i+1][j][k+c][0],x+a[n+1-i]-a[n+1-(i+1)]);
                c=(b[j+1]>=x+L-a[n+1-i]+a[j+1]);
                mn(f[i][j+1][k+c][1],x+L-a[n+1-i]+a[j+1]);
                }
                x=f[i][j][k][1];
                if(x<=1e9)
                {
                //    cout<<i<<' '<<j<<' '<<k<<" 1\n";
                //    cout<<x<<endl;
                    ans=max(ans,k);
                bool c=(b[(n+1-(i+1))]>=x+a[j]+L-a[n+1-(i+1)]);
                mn(f[i+1][j][k+c][0],x+a[j]+L-a[n+1-(i+1)]);
                c=(b[j+1]>=x+a[j+1]-a[j]);
                mn(f[i][j+1][k+c][1],x+a[j+1]-a[j]);
                }
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 3ms
memory: 148264kb

input:

5 180
137 149 164 167 171
18 76 14 55 116

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Wrong Answer
time: 4ms
memory: 148260kb

input:

5 198
5 12 18 190 192
16 43 200 33 0

output:

3

result:

wrong answer 1st lines differ - expected: '4', found: '3'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%