QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#209694#6134. Soldier Gamerqoi031WA 0ms3804kbC++201.3kb2023-10-10 16:40:152023-10-10 16:40:16

Judging History

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

  • [2023-10-10 16:40:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2023-10-10 16:40:15]
  • 提交

answer

#include<stdio.h>
#include<algorithm>
#include<map>
typedef long long ll;
int n;
int a[100005];
std::map<ll,ll> val;
ll calc(const ll m)
{
    if(val.count(m))
    {
        return val[m];
    }
    ll f0(0),f1(__builtin_llabs(m-a[0]));
    for(int j=1;j<n;j++)
    {
        const ll f2(std::min(std::max(f0,__builtin_llabs(m-a[j-1]-a[j])),
                              std::max(f1,__builtin_llabs(m-a[j]))));
        f0=f1,f1=f2;
    }
    return val[m]=f1;
}
void solve()
{
    val.clear();
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",a+i),a[i]<<=1;
    }
    for(int i=20;i<=80;i++)
    {
        printf("%lld ",calc(i)-calc(i-1));
    }
    printf("\n");
    ll s(calc(-4000000000));
    for(ll p=-4000000000;p<4000000000;)
    {
        const ll v(calc(p)),d(calc(p+1)-calc(p));
        ll l(p),r(4000000000);
        while(l<=r)
        {
            const ll m(l+r>>1);
            if(calc(m)==v+d*(m-p))
            {
                l=m+1;
            }
            else
            {
                r=m-1;
            }
        }
        s=std::min(s,calc(r));
        p=r+calc(r)-s;
    }
    printf("%lld\n",s);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3804kb

input:

3
5
-1 4 2 1 1
4
1 3 2 4
1
7

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

wrong answer 2nd numbers differ - expected: '2', found: '1'