QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296523 | #6310. Dining Professors | tangled | WA | 4ms | 3608kb | C++20 | 863b | 2024-01-03 09:11:05 | 2024-01-03 09:11:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using i64 = long long;
void solve()
{
int n, a;
cin >> n >> a;
i64 ans = 0;
vector<int> p;
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
if (x)
ans += 3ll;
else
p.push_back(i);
}
a = n - a;
for (int i = 1; i < p.size(); i++)
{
if (p[i] - p[i - 1] <= 2 && a > 0)
{
ans += 2ll;
a--;
}
}
if (p.size() >= 3)
{
if ((p[p.size() - 1] + 1) % n == p[0] && a >= 0)
{
ans += 2ll;
}
}
cout << ans + a << endl;
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int tc = 1;
// cin >> tc;
while (tc--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3468kb
input:
5 2 1 0 1 0 1
output:
13
result:
ok 1 number(s): "13"
Test #2:
score: -100
Wrong Answer
time: 4ms
memory: 3608kb
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:
254243
result:
wrong answer 1st numbers differ - expected: '279236', found: '254243'