### oleh1421's blog

By oleh1421, history, 6 weeks ago, translation,

## We will hold DIV 2 Kabanchik contest. It starts: 5/23/2022 at 7:00 UTC+0, and end 5/24/2022 at 7:00 UTC+0

Contest is set by: I_LOVE_DASHA_KARPENKO, DJeniUp, oleh1421, timreizin You will be able to give it a try tommorow, you can see results here: kabanchik-raiting.pw

Link to the contest system: kabanchik.contest.codeforces.com

Link to telegram channel with important information: https://t.me/kabanchikthesolver

UPD: contest is already running https://kabanchik.contest.codeforces.com/group/x15RG2CGe8/contest/383227

• +60

 » 6 weeks ago, # |   -6 Auto comment: topic has been translated by oleh1421 (original revision, translated revision, compare)
 » 6 weeks ago, # |   0 Btw, contest will last for 24 hours contain 6 problems. There will be no penalty for submissions. You will be added to the rating table automatically after the end of contest
 » 5 weeks ago, # |   0
 » 5 weeks ago, # |   0 Auto comment: topic has been updated by oleh1421 (previous revision, new revision, compare).
 » 5 weeks ago, # |   0 Contest started. Good luck to everybody!!! You have 24 hours and 6 problems left
 » 5 weeks ago, # |   0 Will there ever be div1?
•  » » 5 weeks ago, # ^ |   0 Yes. I think we will be holding them starting from the next week
 » 5 weeks ago, # |   0 Is rating website working correctly? I can see only 1 user. Also, are the any editorials?
 » 5 weeks ago, # |   0 Can anyone tell why my approach for D is wrong? SpoilerI first reverse the array then I sort the numbers in odd positions after that in even positions then I find the number of inversions of the array. Code/* * ────────────── •✵•✵• ────────────── * | In The Name of *Allah* | * ────────────── •✵•✵• ────────────── */ #ifndef ONLINE_JUDGE #include "debug.h" #else #define deb(x...) #endif #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define si(x) (long long)x.size() #define all(x) x.begin(), x.end() const long long maxn = 2e5 + 10; long long n, a[maxn], b[maxn]; long long merge(long long a[], long long temp[], long long left, long long mid, long long right){ long long inv_count = 0; long long i = left; long long j = mid; long long k = left; while ((i <= mid - 1) && (j <= right)){ if (a[i] <= a[j]){ temp[k++] = a[i++]; } else{ temp[k++] = a[j++]; inv_count = inv_count + (mid - i); } } while (i <= mid - 1){ temp[k++] = a[i++]; } while (j <= right){ temp[k++] = a[j++]; } for (i=left; i <= right; i++){ a[i] = temp[i]; } return inv_count; } long long _mergeSort(long long a[], long long temp[], long long left, long long right){ long long mid, inv_count = 0; if (right > left){ mid = (right + left)/2; inv_count = _mergeSort(a, temp, left, mid); inv_count += _mergeSort(a, temp, mid+1, right); inv_count += merge(a, temp, left, mid+1, right); } return inv_count; } long long ans(long long a[], long long n){ long long temp[n]; return _mergeSort(a, temp, 0, n - 1); } void solve (){ cin >> n; for (long long i = 0; i < n; i++){ cin >> a[i]; b[i] = a[i]; } reverse(a, a + n); vector kom, lom; for (long long i = 0; i < n; i+= 2){ kom.pb(a[i]); } for (long long i = 1; i < n; i+= 2){ lom.pb(a[i]); } sort(all(lom)), sort(all(kom)); long long j = 0; for (long long i = 0; i < n; i+= 2){ a[i] = kom[j]; ++ j; } // deb(kom), deb(lom); j = 0; for (long long i = 1; i < n; i+= 2){ a[i] = lom[j]; ++ j; } cout << ans(a, n); } int main () { ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0); long long tc = 1; // cin >> tc; while (tc --) { solve(); } return 0; } /* Thanks *Allah* */ 
•  » » 5 weeks ago, # ^ | ← Rev. 2 →   0 Consider this testcase: 2 2 1 You will output 0, while answer is 1.
•  » » » 5 weeks ago, # ^ |   0 Well ... I've read the problem wrong :/