| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1355014 | Aviansh | Developer (BOI25_dev) | C++20 | 0 ms | 348 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int arr[n];
for(int &i : arr){
cin >> i;
}
///assume ascending
int pref[n];
pref[0]=arr[0];
for(int i = 1;i<n;i++){
pref[i]=pref[i-1]+arr[i];
}
int ans = 1e18;
for(int m = 0;m<n-1;m++){
///m is included in left group
int lefm = m/2;
int rigm = m+1+(n-m-1)/2;
assert(rigm<n);
int lefcost = ((pref[m]-pref[lefm])-1LL*(m-lefm)*arr[lefm])+(1LL*(lefm+1)*arr[lefm]-pref[lefm]);
int rigcost = ((pref[n-1]-pref[rigm])-1LL*(n-1-rigm)*arr[rigm])+((arr[rigm]*1LL*(rigm-m))-(pref[rigm]-pref[m]));
ans=min(lefcost+rigcost,ans);
}
cout << ans;
return 0;
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
