QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96140#6310. Dining Professorsxuzhihaodedie#WA 10ms4616kbC++201.0kb2023-04-13 13:30:102023-04-13 13:30:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 13:30:12]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:4616kb
  • [2023-04-13 13:30:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
const int mod=998244353;
const int N=4e5+100;
int a[N];
void solve(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++) {
		int x;
		cin>>a[i];
	}
	int ans=0,m=n-k;
	vector<int> st(n+10,0);
	for(int i=1;i<=n;i++)
		if(!a[i])
		{
			for(int j=-1;j<=1;j++)
			{
				if(!m)	break;
				int t = i+j;
				if(t==0)	t=n;
				if(t==n+1)	t=1;
				if(st[t])	continue;
				st[t]=1;
				m--;
			}
			if(!m)	break;
		}
	
	for(int i=1;i<=n;i++)
	{
		if(a[i])
		{
			ans+=3;
			continue; 
		}
		for(int j=-1;j<=1;j++)
		{
			int t = i+j;
			if(t==0)	t=n;
			if(t==n+1)	t=1;
			if(st[t]==1)	ans++;
		}
	}
	cout<<ans<<endl;
}
signed main() {
	int T=1;
//	freopen("C:\\Users\\86153\\Desktop\\data.in.txt","r",stdin); //´ÓÎļþÖлñÈ¡ÊäÈëÁ÷
//	freopen("C:\\Users\\86153\\Desktop\\data1.out.txt","w",stdout); //°ÑÊä³öתµ½ÎļþÖÐ
	//init();
	//cin>>T;
	while(T--) {
		solve();
	}
	//return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3368kb

input:

5 2
1 0 1 0 1

output:

13

result:

ok 1 number(s): "13"

Test #2:

score: -100
Wrong Answer
time: 10ms
memory: 4616kb

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:

264571

result:

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