QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#296523#6310. Dining ProfessorstangledWA 4ms3608kbC++20863b2024-01-03 09:11:052024-01-03 09:11:07

Judging History

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

  • [2024-01-03 09:11:07]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3608kb
  • [2024-01-03 09:11:05]
  • 提交

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'