QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296531 | #6310. Dining Professors | tangled | WA | 6ms | 3844kb | C++20 | 760b | 2024-01-03 09:18:56 | 2024-01-03 09:18:57 |
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;
vector<int> f(n), g(n);
for (int i = 0; i < n; i++)
cin >> f[i];
for (int i = 0; i < n; i++)
{
g[i] += (f[(i - 1 + n) % n] == 0);
g[i] += (f[(i + 1) % n] == 0);
g[i] += (f[i] == 0);
}
sort(g.begin(), g.end());
i64 ans = 0;
for (int i = n - a - 1; i < n; i++)
ans += g[i];
for (int i = 0; i < n; i++)
ans += (f[i] == 1 ? 3 : 0);
cout << ans << 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: 0ms
memory: 3556kb
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: 3844kb
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:
229162
result:
wrong answer 1st numbers differ - expected: '279236', found: '229162'