# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1152224 | Ahmed57 | Line Town (CCO23_day1problem3) | C++20 | 170 ms | 28080 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 2e18;
const int maxn = 5e5 + 5;
int a[maxn], b[maxn], id[maxn];
ll pre[maxn][2], suf[maxn][2], pre2[maxn][2], suf2[maxn][2];
vector<int> vec[2];
ll f[2], g[2];
struct BIT
{
int c[maxn], tot;
void add(int x, int d) { tot += d; for (; x < maxn; x += (x & -x)) c[x] += d; }
int sum(int x) { if (!x) return 0; int ans = 0; for (; x; x -= (x & -x)) ans += c[x]; return ans; }
int gol(int x) { return sum(x - 1); }
int gor(int x) { return tot - sum(x); }
}bit, bit2;
int main()
{
ios::sync_with_stdio(false), cin.tie(0);
int n; cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], b[i] = abs(a[i]), id[i] = i, bit2.add(i, 1);
sort(id + 1, id + n + 1, [&](int x, int y) { return b[x] > b[y]; });
f[0] = 0, f[1] = inf;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |