QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#296531#6310. Dining ProfessorstangledWA 6ms3844kbC++20760b2024-01-03 09:18:562024-01-03 09:18:57

Judging History

你现在查看的是最新测评结果

  • [2024-01-03 09:18:57]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3844kb
  • [2024-01-03 09:18:56]
  • 提交

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'