QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#96140 | #6310. Dining Professors | xuzhihaodedie# | WA | 10ms | 4616kb | C++20 | 1.0kb | 2023-04-13 13:30:10 | 2023-04-13 13:30:12 |
Judging History
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;
}
详细
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'