QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#220731#6310. Dining Professorssmallzhuzi#WA 3ms7672kbC++14807b2023-10-20 19:05:422023-10-20 19:05:43

Judging History

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

  • [2023-10-20 19:05:43]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:7672kb
  • [2023-10-20 19:05:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ld long double  
#define pb push_back 
#define endl "\n" 
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend() 
typedef pair<int,int> pii;
const int N=1000010,inf=LLONG_MAX,mod=998244353;

int t,n,m,a[N],b[N],vis[N];
string yes="Yes",no="No"; 

void solve(){
	cin>>n>>m;
	int ans=n*3;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		b[i]=a[i-1]+a[i]+a[i+1];
	}
	b[1]+=a[n];
	b[n]+=a[1];
	sort(b+1,b+n+1);
	for(int i=n;i>=1;i--){
		if(m==0)break;
		m--;
		if(b[i]==2)ans--;
		else if(b[i]==1)ans-=2;
		else ans-=3;
	}
	cout<<ans<<endl;
}

signed main(){
 	ios::sync_with_stdio(0);
	cin.tie(0);
	t=1; 
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 7540kb

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:

241652

result:

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