QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#292936 | #6310. Dining Professors | zxzxzxq# | WA | 6ms | 4224kb | C++14 | 855b | 2023-12-28 17:13:34 | 2023-12-28 17:13:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i64 = long long ;
const i64 N = 1e5 + 10;
i64 n, m;
i64 a[N], cnt[4];
i64 cntsp;
void solve()
{
cin >> n >> m;
for(i64 i = 1;i <= n;i ++)
{
cin >> a[i];
if (a[i]) cntsp ++;
}
a[n + 1] = a[1], a[0] = a[n];
for(i64 i = 1;i <= n;i ++)
{
i64 t = 0;
if (a[i] = 0) t ++;
if (a[i - 1] == 0) t ++;
if (a[i + 1] == 0) t ++;
cnt[t] ++;
}
i64 ans = cntsp * 3;
i64 dish = n - m;
for(int i = 3;i ;i --)
{
ans += i * min(dish, cnt[i]);
dish -= min(dish, cnt[i]);
}
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3340kb
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: 4224kb
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:
266744
result:
wrong answer 1st numbers differ - expected: '279236', found: '266744'