QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#302350 | #6310. Dining Professors | Fengfeng | WA | 6ms | 4168kb | C++20 | 698b | 2024-01-10 19:37:24 | 2024-01-10 19:37:25 |
Judging History
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;
}
詳細信息
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'