QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#684058#7624. Mystery of Primelanos212#WA 3ms9112kbC++20807b2024-10-28 09:40:232024-10-28 09:40:24

Judging History

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

  • [2024-10-28 09:40:24]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:9112kb
  • [2024-10-28 09:40:23]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

int n,a[300001],f[300001],b[300001],mi=1e18;

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

b[1]=1;
for (int i=2;i<=300000;++i) if (!b[i]) for (int j=i+i;j<=300000;j+=i) b[j]=1;

cin>>n;
for (int i=1;i<=n;++i) cin>>a[i];
for (int i=1;i<=n;++i){
f[i]=i-1;
if (i>=2 && !b[a[i]+a[i-1]]) f[i]=min(f[i],f[i-1]);
for (int j=2;j<=3;++j)
if (i-j>=1 && (abs(a[i]-a[i-j])%2==j%2 || (!b[a[i]+1] && !b[a[i-j]+1]) || a[i]==1 || a[i-j]==1))
f[i]=min(f[i],f[i-j]+j-1);
if (i>=5 && (abs(a[i]-a[i-4])%2==0 || !b[a[i]+1] || !b[a[i-4]+1])) f[i]=min(f[i],f[i-4]+3);
f[i]=min(f[i],mi+i-1);
if (i>=5) mi=min(mi,f[i-4]-(i-4));
}

int ans=1e18;
for (int i=1;i<=n;++i) ans=min(ans,f[i]+(n-i));
cout<<ans<<'\n';

return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 9112kb

input:

6
1 5 1 4 4 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 8364kb

input:

9
30 6 7 12 15 8 20 17 14

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 8456kb

input:

1568
119 519 706 1003 1317 322 25 1466 816 525 1 1122 38 1511 774 515 274 780 647 230 1602 1051 810 1 1 1232 1 1202 1583 412 1111 168 309 1181 184 1260 491 764 809 1213 804 1470 1 1087 1235 1004 673 1338 1333 1392 1036 1539 268 1 712 727 297 404 1317 36 463 1067 1133 693 931 46 1 100 1608 965 1 1406...

output:

710

result:

wrong answer 1st numbers differ - expected: '733', found: '710'