QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#292064 | #6310. Dining Professors | Ycfhnnd | WA | 6ms | 4164kb | C++20 | 775b | 2023-12-27 16:57:23 | 2023-12-27 16:57:23 |
Judging History
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'