# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
117505 |
2019-06-16T10:25:48 Z |
FutymyClone |
Krov (COCI17_krov) |
C++14 |
|
19 ms |
1784 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N];
long long check (int mid) {
long long sum = 0;
int Min = 2e9 + 2277;
for (int i = 1; i <= n; i++) {
int need = a[mid] - abs(i - mid);
sum += abs(need - a[i]);
Min = min(Min, need);
}
if (Min <= 0) {
sum = 0;
for (int i = 1; i <= n; i++) {
int need = a[mid] + 1 - Min - abs(i - mid);
sum += abs(need - a[i]);
}
}
return sum;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
//for (int i = 1; i <= n; i++) cout << check(i) << " ";
//return 0;
int l = 1, r = n;
while (l <= r) {
int mid = (l + r) >> 1;
if (check(mid) < check(mid + 1)) r = mid - 1;
else l = mid + 1;
}
cout << check(l);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
1280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
1784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |