QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#220730#6310. Dining Professorssmallzhuzi#WA 5ms7784kbC++14778b2023-10-20 19:03:382023-10-20 19:03:38

Judging History

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

  • [2023-10-20 19:03:38]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:7784kb
  • [2023-10-20 19:03:38]
  • 提交

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];
		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;
}

詳細信息

Test #1:

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

input:

5 2
1 0 1 0 1

output:

13

result:

ok 1 number(s): "13"

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 7784kb

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:

258443

result:

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