# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
236738 |
2020-06-03T07:31:52 Z |
VEGAnn |
Krov (COCI17_krov) |
C++14 |
|
1500 ms |
1152 KB |
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define ft first
#define sd second
using namespace std;
typedef long long ll;
const int N = 100100;
const int oo = int(2e9);
const ll OO = 1e18;
const int md = int(1e9) + 7;
int n;
ll x[N], ans = OO;
ll get(int id, ll ht){
ll cur = 0;
for (int i = 0; i < n; i++)
cur += abs(x[i] - (ht - abs(i - id)));
return cur;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n;
for (int i = 0; i < n; i++)
cin >> x[i];
for (int i = 0; i < n; i++){
ll l = max(i + 1, n - i), r = ll(1e9);
while (l + 5 < r){
ll md = (l + r) >> 1;
if (get(i, md) < get(i, md + 1))
r = md;
else l = md + 1;
}
for (ll j = l; j <= r; j++)
ans = min(ans, get(i, j));
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
384 KB |
Output is correct |
2 |
Correct |
122 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
384 KB |
Output is correct |
2 |
Correct |
127 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
252 ms |
384 KB |
Output is correct |
2 |
Correct |
267 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
426 ms |
384 KB |
Output is correct |
2 |
Correct |
475 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
853 ms |
444 KB |
Output is correct |
2 |
Correct |
606 ms |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1588 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1590 ms |
512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1586 ms |
640 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1591 ms |
896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1584 ms |
1152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |