QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#125595 | #6626. Real Mountains | bashkort | 0 | 1ms | 3440kb | C++20 | 1.8kb | 2023-07-16 23:38:26 | 2023-07-16 23:38:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 1e6 + 3;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; ++i) {
cin >> h[i];
}
ll best = 3e18;
int p = max_element(h.begin(), h.end()) - h.begin();
vector<bool> used(n);
ll ans = 0;
int f = 0;
while (count(used.begin(), used.end(), false)) {
int i = -1;
if (f == 0) {
for (int j = 0; j < n; ++j) {
if (!used[j] && (i == -1 || h[i] > h[j])) {
i = j;
}
}
} else {
for (int j = n - 1; j >= 0; --j) {
if (!used[j] && (i == -1 || h[i] > h[j])) {
i = j;
}
}
}
bool ok = false;
if (i <= p) {
if (*max_element(h.begin(), h.begin() + i + 1) == h[i]) {
ok = true;
}
}
if (i >= p) {
if (*max_element(h.begin() + i, h.end()) == h[i]) {
ok = true;
}
}
if (ok) {
used[i] = true;
continue;
}
f ^= 1;
int l = 1e9, r = 1e9;
for (int j = 0; j < i; ++j) {
if (h[j] > h[i]) {
l = min(l, h[j]);
}
}
for (int j = i + 1; j < n; ++j) {
if (h[j] > h[i]) {
r = min(r, h[j]);
}
}
ans = ans + l + r + h[i];
h[i] += 1;
}
for (int x : h) {
cout << x << " ";
}
cout << '\n';
best = min(best, ans);
cout << best % MOD << '\n';
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3440kb
input:
3 29 9 9
output:
29 9 9 0
result:
wrong answer 1st numbers differ - expected: '0', found: '29'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #3:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%