QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#302761 | #6310. Dining Professors | Szy# | WA | 3ms | 4188kb | C++23 | 839b | 2024-01-11 11:45:24 | 2024-01-11 11:45:25 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'