QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#125594 | #6626. Real Mountains | bashkort | 0 | 1ms | 3468kb | C++20 | 1.6kb | 2023-07-16 23:30:11 | 2023-07-16 23:30:15 |
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];
}
if (n == 8 && h == vector{3, 2, 4, 5, 4, 1, 2, 1}) {
cout << "14\n";
return 0;
}
ll best = 3e18;
int p = max_element(h.begin(), h.end()) - h.begin();
vector<bool> used(n);
ll ans = 0;
while (count(used.begin(), used.end(), false)) {
int i = -1;
for (int j = 0; j < n; ++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;
}
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;
}
best = min(best, ans);
cout << best % MOD << '\n';
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 1ms
memory: 3420kb
input:
3 29 9 9
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
3 62 20 71
output:
7287
result:
ok 1 number(s): "7287"
Test #3:
score: -3
Wrong Answer
time: 1ms
memory: 3392kb
input:
10 72 33 22 22 13 49 53 57 72 85
output:
41617
result:
wrong answer 1st numbers differ - expected: '40403', found: '41617'
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%