QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#259816 | #2175. Growing Vegetables is Fun 4 | Camillus# | 0 | 1ms | 3772kb | C++20 | 709b | 2023-11-21 14:30:56 | 2024-07-04 03:08:04 |
answer
/// @author Camillus
#include "bits/stdc++.h"
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> left(n), right(n);
for (int i = 1; i < n; i++) {
left[i] = left[i - 1] + max(0ll, a[i - 1] - a[i] + 1);
}
for (int i = n - 2; i >= 0; i--) {
right[i] = right[i + 1] + max(0ll, a[i + 1] - a[i] + 1);
}
int ans = INT32_MAX;
for (int i = 0; i < n; i++) {
ans = min(ans, max(left[i], right[i]));
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 40
Accepted
time: 1ms
memory: 3520kb
input:
2 569756508 265577686
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
2 905574077 905574077
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
3 970577574 477262134 791905208
output:
314643075
result:
ok single line: '314643075'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
3 634647532 634647532 634647532
output:
1
result:
ok single line: '1'
Test #5:
score: -40
Wrong Answer
time: 1ms
memory: 3572kb
input:
1999 835109617 608292283 618117484 497958957 611607015 70168164 477454019 70333286 821931315 104232697 234095331 41806748 813743448 676090182 776662569 441747966 907663428 993530698 7954955 202095258 789793212 448943101 515564795 68382202 507155724 819747128 339256745 491780118 461177551 81438287 48...
output:
2147483647
result:
wrong answer 1st lines differ - expected: '166120578451', found: '2147483647'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%