QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302350#6310. Dining ProfessorsFengfengWA 6ms4168kbC++20698b2024-01-10 19:37:242024-01-10 19:37:25

Judging History

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

  • [2024-01-10 19:37:25]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:4168kb
  • [2024-01-10 19:37:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
long long ksm(long long a,long long b,long long mod){
	long long res=1;
	a%=mod;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

void solve(){
	int n,a;
	cin>>n>>a;
	vector<int>b(n+2,0);
	int t=0;
	for(int i=1;i<=n;i++){
		cin>>b[i];
		t+=b[i];
	}	
	int ans=n*3;
	vector<int>q;
	b[0]=b[n];b[n+1]=b[1];
	for(int i=1;i<=n;i++){
		q.push_back((b[i-1]==0)+(b[i]==0)+(b[i+1]==0));
	}
	sort(q.begin(),q.end());
	for(int i=1;i<=a;i++){
		ans-=q[i];
	}

	cout<<ans<<'\n';
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 2
1 0 1 0 1

output:

13

result:

ok 1 number(s): "13"

Test #2:

score: -100
Wrong Answer
time: 6ms
memory: 4168kb

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:

279235

result:

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