QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#768304#6310. Dining ProfessorsWsyWA 6ms4760kbC++231014b2024-11-21 08:52:222024-11-21 08:52:22

Judging History

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

  • [2024-11-21 08:52:22]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:4760kb
  • [2024-11-21 08:52:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,m,cnt,ans;
int a[maxn];
bool flag[maxn];
int main() {
	scanf("%d%d",&n,&m);
	m=n-m;
	for (int i=1;i<=n;i++) {
	    scanf("%d",&a[i]);
		if (a[i]) ans+=3;
		a[i+n]=a[i];
	}
	for (int i=1;i<=n;i++) {
		if (!a[i] && !a[i+1] && !a[i+2]) flag[i+1]=1,ans+=3,cnt++;
	}
	if (flag[n+1]) flag[1]=1;
	if (cnt>=m) {
		printf("%d\n",ans);
		return 0;
	}
	for (int i=1;i<=n;i++) {
		if (flag[i+1]) continue;
		int s=0;
		if (!a[i]) s++;
		if (!a[i+1]) s++;
		if (!a[i+2]) s++;
		if (s==2) {
			flag[i+1]=1;
			ans+=2;
			cnt++;
			if (cnt==m) {
				printf("%d\n",ans);
				return 0;
			}
		}
	}
	if (flag[n+1]) flag[1]=1;
	for (int i=1;i<=n;i++) {
		if (flag[i+1]) continue;
		int s=0;
		if (!a[i]) s++;
		if (!a[i+1]) s++;
		if (!a[i+2]) s++;
		if (s==1) {
			flag[i+1]=1;
			ans++;
			cnt++;
			if (cnt==m) {
				printf("%d\n",ans);
				return 0;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3904kb

input:

5 2
1 0 1 0 1

output:

13

result:

ok 1 number(s): "13"

Test #2:

score: 0
Accepted
time: 6ms
memory: 4608kb

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:

279236

result:

ok 1 number(s): "279236"

Test #3:

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

input:

100000 91906
1 1 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 1 0 1 0 1 1 0 0 1 0...

output:

187545

result:

wrong answer 1st numbers differ - expected: '174297', found: '187545'