QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#302825 | #6310. Dining Professors | ZYF_B# | WA | 1ms | 5804kb | C++14 | 971b | 2024-01-11 13:46:15 | 2024-01-11 13:46:16 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define re register
#define INF 2147483647
using namespace std;
inline int read()
{
int f=1,x=0;char s=getchar();
while(s<'0'||s>'9')
{
if(s=='-') f=-1;
s=getchar();
}
while(s>='0'&&s<='9')
{
x=x*10+s-48;
s=getchar();
}
return f*x;
}
const int N=1e6+5;
int a[N],b[N];
vector<int> v[4];
int main()
{
int n=read(),m=read();
for(int i=1;i<=n;i++) a[i]=read();
int ans=0;
for(int i=1;i<=n;i++)
{
int pre=(i+n-2)%n+1;
int lst=i%n+1;
int x=a[pre]+a[lst]+a[i];
v[x].push_back(i);
cout<<x<<endl;
}
int res=m;
for(int i=3;i>=0;i--)
{
if(res==0) break;
for(int j=0;j<v[i].size();j++)
{
b[v[i][j]]=1;
// cout<<v[i][j]<<endl;
res--;
if(res==0) break;
}
}
for(int i=1;i<=n;i++)
{
int pre=(i+n-2)%n+1;
int lst=i%n+1;
int x=b[pre]+b[lst]+b[i];
if(a[i]) ans+=3;
else ans+=3-x;
}
printf("%d\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5804kb
input:
5 2 1 0 1 0 1
output:
2 2 1 2 2 13
result:
wrong answer 1st numbers differ - expected: '13', found: '2'