QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#292064#6310. Dining ProfessorsYcfhnndWA 6ms4164kbC++20775b2023-12-27 16:57:232023-12-27 16:57:23

Judging History

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

  • [2023-12-27 16:57:23]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:4164kb
  • [2023-12-27 16:57:23]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int>a(n);
    for (int i = 0;i < n;i ++){
        cin >> a[i];
    }
    vector<int>v;
    for (int i = 0;i < n;i ++){
        int cnt = 0;
        cnt += a[i] == 1;
        cnt += (a[(i + 1) % n] == 1);
        cnt += (a[(i + n - 2) % n + 1] == 1);
        v.push_back(cnt);
    }
    sort(v.rbegin(), v.rend());
    int ans = 0;
    for (int i = 0;i < m;i ++){
        ans += v[i];
    }
    ans += 3 * (n - m);
    cout << ans << "\n";

}   

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3764kb

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: 4164kb

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:

279235

result:

wrong answer 1st numbers differ - expected: '279236', found: '279235'