QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140797 | #6310. Dining Professors | supepapupu | WA | 4ms | 3628kb | C++17 | 1.5kb | 2023-08-16 20:30:48 | 2023-08-16 20:30:50 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
inline int read() {
int f = 1, k = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
k = k * 10 + c - '0';
c = getchar();
}
return f * k;
}
int main() {
int n = read(), k = read();
vector<int> a(n + 2);
vector<bool> st(n + 1);
for (int i = 1; i <= n; ++i) a[i] = read();
a[0] = a[n], a[n + 1] = a[1];
for (int i = 1; i <= n; ++i) {
if (k && a[i - 1] + a[i] + a[i + 1] == 3) {
--k;
st[i] = 1;
}
}
for (int i = 1; i <= n; ++i) {
if (!st[i] && k && a[i - 1] + a[i] + a[i + 1] == 2) {
--k;
st[i] = 1;
}
}
for (int i = 1; i <= n; ++i) {
if (!st[i] && k && a[i - 1] + a[i] + a[i + 1] == 1) {
--k;
st[i] = 1;
}
}
for (int i = 1; i <= n; ++i) {
if (k) {
--k;
st[i] = 1;
}
}
ll ans = 0;
st[0] = st[n], st[n + 1] = st[1];
for (int i = 1; i <= n; ++i) {
if (a[i]) ans += 3;
else ans += !st[i - 1] + !st[i] + !st[i + 1];
}
cout << ans;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3548kb
input:
5 2 1 0 1 0 1
output:
13
result:
ok 1 number(s): "13"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
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:
279236
result:
ok 1 number(s): "279236"
Test #3:
score: -100
Wrong Answer
time: 4ms
memory: 3628kb
input:
100000 91906 1 1 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 1 0 1 0 1 1 0 0 1 0...
output:
185874
result:
wrong answer 1st numbers differ - expected: '174297', found: '185874'