QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296193 | #6310. Dining Professors | SaladDays# | WA | 6ms | 4604kb | C++14 | 756b | 2024-01-02 13:47:44 | 2024-01-02 13:47:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int>a(n);
for(int i = 0; i < n; ++i) cin >> a[i];
vector<int>b(n), key(n), c(n, 0);
long long ans = 3 * n;
for (int i = 0; i < n; ++i) {
b[i] = a[i] + a[(i + 1) % n] + a[(i + n - 1) % n];
}
iota(key.begin(), key.end(), 0);
sort(key.begin(), key.end(), [&](int x, int y){
return b[x] > b[y];
});
for (int i = 0; i < k; ++i) ans -= 3 - b[i];
cout << ans << endl;
}
int main() {
#ifdef DEBUG
freopen("demo.in", "r", stdin);
freopen("demo.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 4604kb
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:
250073
result:
wrong answer 1st numbers differ - expected: '279236', found: '250073'