QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302761#6310. Dining ProfessorsSzy#WA 3ms4188kbC++23839b2024-01-11 11:45:242024-01-11 11:45:25

Judging History

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

  • [2024-01-11 11:45:25]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4188kb
  • [2024-01-11 11:45:24]
  • 提交

answer

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

int n,a;
int b[100003];
vector<int> gx;
int cmp(int a,int b)
{
    return a>b;
}
void sol()
{
    scanf("%d%d",&n,&a);
    int ans=0,can=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&b[i]);
        if(b[i]==1)++can;
        /*int l=(i+n-2)%n+1;
        int r=(i%n)+1;*/
        //printf("%d [%d %d]\n",i,l,r);
    }
    for(int i=1;i<=n-a;++i)
    {
        int cnt=0;
        int l=(i+n-2)%n+1;
        int r=(i%n)+1;
        if(b[l]==0)++cnt;
        if(b[i]==0)++cnt;
        if(b[r]==0)++cnt;
        gx.push_back(cnt);
    }
    sort(gx.begin(),gx.end(),cmp);
    for(int i=0;i<n-a;++i)
    {
        //printf("[%d]\n",gx[i]);
        ans+=gx[i];
    }
    ans+=3*can;
    printf("%d\n",ans);
}
int main()
{
    sol();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3864kb

input:

5 2
1 0 1 0 1

output:

13

result:

ok 1 number(s): "13"

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 4188kb

input:

100000 33292
1 1 1 1 0 1 1 0 0 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 1 0 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 0 0...

output:

250103

result:

wrong answer 1st numbers differ - expected: '279236', found: '250103'