QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#117282#6627. Line Townpandapythoner#13 538ms51656kbC++207.3kb2023-06-30 20:40:262024-05-31 18:44:03

Judging History

你现在查看的是最新测评结果

  • [2024-05-31 18:44:03]
  • 评测
  • 测评结果:13
  • 用时:538ms
  • 内存:51656kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 20:40:26]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

mt19937 rnd(234);
const ll inf = 1e17;

struct SGT {
    int n;
    vector<int> t;

    void build(int _n) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        t.assign(n + n, 0);
    }

    void chng(int i, int x) {
        i += n;
        t[i] = x;
        for (i /= 2; i >= 1; i /= 2) {
            t[i] = t[i + i] + t[i + i + 1];
        }
    }

    int get(int l, int r) {
        l += n;
        r += n + 1;
        int rs = 0;
        while (l < r) {
            if (l & 1) {
                rs += t[l];
                l += 1;
            }
            if (r & 1) {
                r -= 1;
                rs += t[r];
            }
            l /= 2;
            r /= 2;
        }
        return rs;
    }
};

int n;
vector<ll> h;

ll solve_abs_1() {
    vector<int> a(n + 2);
    a[0] = 0;
    a[n + 1] = 1;
    for (int i = 0; i < n; i += 1) {
        if (h[i] < 0) {
            a[i + 1] = 0;
        } else {
            a[i + 1] = 1;
        }
    }
    vector<int> d(n + 1);
    for (int i = 0; i <= n; i += 1) {
        d[i] = (a[i] ^ a[i + 1]);
    }
    vector<int> stck;
    vector<ll> bebra(n + 1, inf);
    ll sm = 0;
    for (int i = 0; i <= n; i += 1) {
        if (d[i]) {
            if (!stck.empty() && stck.back() % 2 == i % 2) {
                sm += (i - stck.back()) / 2;
                stck.pop_back();
            } else {
                stck.push_back(i);
            }
            if (stck.size() == 1) {
                bebra[i] = sm;
            }
        }
    }
    ll rs = inf;
    stck.clear();
    sm = 0;
    for (int i = n; i >= 0; i -= 1) {
        if (stck.empty()) {
            rs = min(rs, sm + bebra[i]);
        }
        if (d[i]) {
            if (!stck.empty() && stck.back() % 2 == i % 2) {
                sm += (stck.back() - i) / 2;
                stck.pop_back();
            } else {
                stck.push_back(i);
            }
        }
    }
    if (rs > inf / 4) {
        return -1;
    }
    return rs;
}

ll solve_distinct() {
    vector<ll> a(n);
    vector<ll> neg(n);
    for (int i = 0; i < n; i += 1) {
        if (h[i] < 0) {
            neg[i] = 1;
        }
        a[i] = abs(h[i]);
    }
    vector<pair<ll, int>> srtd(n);
    for (int i = 0; i < n; i += 1) {
        srtd[i] = make_pair(a[i], i);
    }
    sort(rall(srtd));
    array<ll, 2> dp = {0, inf};
    SGT sgt;
    sgt.build(n);
    for (int i = 0; i < n; i += 1) {
        sgt.chng(i, 1);
    }
    for (int itr = 0; itr < n; itr += 1) {
        int i = srtd[itr].second;
        sgt.chng(i, 0);
        array<ll, 2> new_dp = {inf, inf};
        for (int lx = 0; lx < 2; lx += 1) {
            int rx = (n - 1 + lx + itr) % 2;
            if ((neg[i] + i + lx) % 2 == 1) {
                new_dp[lx ^ 1] = min(new_dp[lx ^ 1], dp[lx] + sgt.get(0, i));
            }
            if ((neg[i] + i + rx) % 2 == 0) {
                new_dp[lx] = min(new_dp[lx], dp[lx] + sgt.get(i, n - 1));
            }
        }
        dp = new_dp;
    }
    ll rs = inf;
    for (int lx = 0; lx < 2; lx += 1) {
        rs = min(rs, dp[lx]);
    }
    if (rs > inf / 4) {
        return -1;
    }
    return rs;
}

ll solve() {
    vector<ll> a(n);
    vector<ll> neg(n);
    for (int i = 0; i < n; i += 1) {
        if (h[i] < 0) {
            neg[i] = 1;
        }
        a[i] = abs(h[i]);
    }
    vector<pair<ll, int>> srtd(n);
    for (int i = 0; i < n; i += 1) {
        srtd[i] = make_pair(a[i], i);
    }
    sort(rall(srtd));
    array<ll, 2> dp = {0, inf};
    SGT sgt;
    sgt.build(n);
    for (int i = 0; i < n; i += 1) {
        sgt.chng(i, 1);
    }
    for (int itr = 0; itr < n;) {
        int itr_nd = itr + 1;
        while (itr_nd < n && srtd[itr_nd].first == srtd[itr].first) {
            itr_nd += 1;
        }
        array<deque<int>, 2> arr = {deque<int>(), deque<int>()};
        for (int t = itr; t < itr_nd; t += 1) {
            int i = srtd[t].second;
            arr[(neg[i] + i) % 2].push_back(i);
        }
        for (int s = 0; s < 2; s += 1) {
            sort(all(arr[s]));
        }
        array<ll, 2> new_dp = {inf, inf};
        for (int _lx = 0; _lx < 2; _lx += 1) {
            ll aboba = dp[_lx];
            int lx = _lx;
            int rx = (n - 1 + lx + itr) % 2;
            for (int s = 0; s < 2; s += 1) {
                for (auto i : arr[s]) {
                    sgt.chng(i, 1);
                }
            }
            vector<int> stckl;
            vector<int> stckr;
            auto arr_cp = arr;
            ll sm = 0;
            while (!arr_cp[lx ^ 1].empty()) {
                int i = arr_cp[lx ^ 1].front();
                sgt.chng(i, 0);
                sm += sgt.get(0, i);
                stckl.push_back(i);
                arr_cp[lx ^ 1].pop_front();
                lx ^= 1;
            }
            while (!arr_cp[rx].empty()) {
                int i = arr_cp[rx].back();
                sgt.chng(i, 0);
                sm += sgt.get(i, n - 1);
                stckr.push_back(i);
                arr_cp[rx].pop_back();
                rx ^= 1;
            }
            if (!arr_cp[0].empty() || !arr_cp[1].empty()) {
                continue;
            }
            while (1) {
                new_dp[lx] = min(new_dp[lx], aboba + sm);
                if (stckl.empty()) {
                    break;
                }
                int i = stckl.back();
                stckl.pop_back();
                lx ^= 1;
                sm -= sgt.get(0, i);
                sgt.chng(i, 1);

                if ((i + neg[i] + rx) % 2 == 0) {
                    stckr.push_back(i);
                    rx ^= 1;
                    sgt.chng(i, 0);
                    sm += sgt.get(i, n - 1);
                    continue;
                }
                if (stckl.empty()) {
                    break;
                }
                int j = stckl.back();
                stckl.pop_back();
                lx ^= 1;
                sm -= sgt.get(0, j);
                sgt.chng(j, 1);

                stckr.push_back(j);
                rx ^= 1;
                sgt.chng(j, 0);
                sm += sgt.get(j, n - 1);

                stckr.push_back(i);
                rx ^= 1;
                sgt.chng(i, 0);
                sm += sgt.get(i, n - 1);
            }
        }
        for (int s = 0; s < 2; s += 1) {
            for (auto i : arr[s]) {
                sgt.chng(i, 0);
            }
        }
        dp = new_dp;
        itr = itr_nd;
    }
    ll rs = inf;
    for (int lx = 0; lx < 2; lx += 1) {
        rs = min(rs, dp[lx]);
    }
    if (rs > inf / 4) {
        return -1;
    }
    return rs;
}

int32_t main() {
    if (1) {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    cin >> n;
    h.resize(n);
    for (int i = 0; i < n; i += 1) {
        cin >> h[i];
    }
    cout << solve() << "\n";
    return 0;
}

/*
6
-2 7 -1 -8 2 8


4
1 -1 1 -1

4
1 1 -1 -1


6
-2 7 -1 -8 2 9


*/

详细

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 1ms
memory: 3864kb

input:

10
1 1 1 1 1 -1 -1 -1 1 -1

output:

-1

result:

ok 1 number(s): "-1"

Test #2:

score: 3
Accepted
time: 0ms
memory: 3672kb

input:

10
1 1 1 1 1 1 -1 1 1 -1

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 3
Accepted
time: 0ms
memory: 3548kb

input:

1
-1

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 3
Accepted
time: 1ms
memory: 3856kb

input:

2000
1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 ...

output:

15146

result:

ok 1 number(s): "15146"

Test #5:

score: 3
Accepted
time: 0ms
memory: 3804kb

input:

2000
-1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 -1 -1 -1 ...

output:

24933

result:

ok 1 number(s): "24933"

Test #6:

score: 3
Accepted
time: 1ms
memory: 3896kb

input:

2000
1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 1 1 1 -1 1 1 1 1 -1 -1 1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 -...

output:

18090

result:

ok 1 number(s): "18090"

Test #7:

score: 3
Accepted
time: 1ms
memory: 3784kb

input:

2000
-1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 1 1 1...

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

score: 3
Accepted
time: 0ms
memory: 4096kb

input:

2000
-1 1 -1 1 1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 ...

output:

9973

result:

ok 1 number(s): "9973"

Test #9:

score: 3
Accepted
time: 1ms
memory: 3828kb

input:

2000
-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 ...

output:

499500

result:

ok 1 number(s): "499500"

Test #10:

score: 3
Accepted
time: 1ms
memory: 3804kb

input:

2000
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

499500

result:

ok 1 number(s): "499500"

Test #11:

score: 3
Accepted
time: 1ms
memory: 4092kb

input:

1999
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

499500

result:

ok 1 number(s): "499500"

Test #12:

score: 3
Accepted
time: 0ms
memory: 3720kb

input:

1997
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

498501

result:

ok 1 number(s): "498501"

Test #13:

score: 3
Accepted
time: 1ms
memory: 3836kb

input:

2000
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

-1

result:

ok 1 number(s): "-1"

Subtask #2:

score: 3
Accepted

Dependency #1:

100%
Accepted

Test #14:

score: 3
Accepted
time: 0ms
memory: 3676kb

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 3
Accepted
time: 260ms
memory: 49064kb

input:

500000
1 -1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 1 1 -1 -1 -1 1 -1 1 1 1 1 1 1 1 -1 -1 1 1 -1 1 1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 1 1 1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 1 -1 -1 1 ...

output:

29737766

result:

ok 1 number(s): "29737766"

Test #16:

score: 3
Accepted
time: 248ms
memory: 48824kb

input:

500000
1 -1 -1 1 1 1 1 1 1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 1 1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1...

output:

66957355

result:

ok 1 number(s): "66957355"

Test #17:

score: 3
Accepted
time: 254ms
memory: 49136kb

input:

500000
1 -1 1 1 1 -1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 1 -1 1 1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1...

output:

50480873

result:

ok 1 number(s): "50480873"

Test #18:

score: 3
Accepted
time: 173ms
memory: 47372kb

input:

500000
-1 1 1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 1 1 1 -1 1 1 -1 1 1 -1 1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 1 -1 1 -1 1 -1 1 1 1 1 1 -1 1 -1 1 1 1 -1 -1 -1 -1...

output:

-1

result:

ok 1 number(s): "-1"

Test #19:

score: 3
Accepted
time: 336ms
memory: 51656kb

input:

500000
1 1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1...

output:

90473670

result:

ok 1 number(s): "90473670"

Test #20:

score: 3
Accepted
time: 334ms
memory: 50932kb

input:

500000
-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

31249875000

result:

ok 1 number(s): "31249875000"

Test #21:

score: 3
Accepted
time: 338ms
memory: 50936kb

input:

500000
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -...

output:

31249875000

result:

ok 1 number(s): "31249875000"

Test #22:

score: 3
Accepted
time: 338ms
memory: 51112kb

input:

499999
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -...

output:

31249875000

result:

ok 1 number(s): "31249875000"

Test #23:

score: 3
Accepted
time: 351ms
memory: 51052kb

input:

499997
-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ...

output:

31249375003

result:

ok 1 number(s): "31249375003"

Test #24:

score: 3
Accepted
time: 261ms
memory: 51164kb

input:

500000
1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -...

output:

-1

result:

ok 1 number(s): "-1"

Subtask #3:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #25:

score: 0
Wrong Answer
time: 0ms
memory: 3904kb

input:

10
0 1 0 0 1 1 -1 0 1 -1

output:

10

result:

wrong answer 1st numbers differ - expected: '9', found: '10'

Subtask #4:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #44:

score: 0
Wrong Answer
time: 239ms
memory: 39980kb

input:

500000
1 1 -1 0 0 -1 1 -1 0 0 1 1 -1 -1 -1 1 -1 1 0 0 -1 1 1 0 0 0 0 0 1 0 -1 0 -1 1 1 0 0 -1 1 0 0 0 0 0 -1 0 0 -1 1 1 0 0 1 0 0 1 -1 0 1 0 0 0 0 -1 1 0 1 0 -1 0 -1 1 1 0 -1 0 0 0 0 0 0 1 -1 1 -1 1 0 1 -1 0 1 -1 0 -1 -1 1 1 0 1 0 -1 0 0 0 -1 0 -1 0 0 1 -1 1 0 0 1 0 1 0 1 0 0 -1 0 1 1 -1 -1 0 0 -1 -...

output:

-1

result:

wrong answer 1st numbers differ - expected: '15602272809', found: '-1'

Subtask #5:

score: 4
Accepted

Test #60:

score: 4
Accepted
time: 0ms
memory: 3636kb

input:

10
3 10 5 -9 7 2 -6 1 8 0

output:

-1

result:

ok 1 number(s): "-1"

Test #61:

score: 4
Accepted
time: 0ms
memory: 3892kb

input:

10
-9 0 -1 7 5 10 6 3 2 -8

output:

13

result:

ok 1 number(s): "13"

Test #62:

score: 4
Accepted
time: 2ms
memory: 3720kb

input:

2000
40667 -598150 -1084780 1201651 1570514 -1859539 -2029075 2941581 -2945945 3038404 3447919 5293872 -5335692 -5669647 5973784 6041345 6346915 -7222112 8820986 -9153143 9563103 9749206 -9894732 -11847193 11987150 12161864 13336572 13528051 -13722732 -13836176 -15497141 -15841563 15862227 16618123 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #63:

score: 4
Accepted
time: 2ms
memory: 3780kb

input:

2000
3038404 -798315545 693574695 172661079 516504064 164016456 193562146 -131746730 382134316 -398886978 188767854 -834289064 -965673210 -826409444 -281381674 450991903 -592752625 81651101 -594873306 -352059270 -651772982 540062674 -769881300 68999588 307151563 -129950325 550154987 354801227 840540...

output:

658039

result:

ok 1 number(s): "658039"

Test #64:

score: 4
Accepted
time: 2ms
memory: 3664kb

input:

2000
-1095 -925 -1049 -1519 951 -1673 -776 345 -38 -1735 -276 -1730 123 -1629 -1896 -1576 -1115 1145 15 797 -948 287 1487 1195 1269 -1240 -1571 -275 -1915 -369 -1221 -1590 -1392 -100 1688 -1287 -241 1130 -1375 -965 669 -147 -307 -795 -1207 1939 120 -305 -915 -1078 -1448 1458 -603 1935 658 774 1471 7...

output:

668545

result:

ok 1 number(s): "668545"

Test #65:

score: 4
Accepted
time: 2ms
memory: 3780kb

input:

2000
1290 1487 -1947 -255 457 -1202 1313 36 -1511 898 1739 987 1809 -1986 -1015 -1127 -703 -223 179 557 199 349 1099 -259 -1401 -1244 -1116 646 -295 1713 1512 127 -1660 343 -1921 -1326 -549 831 1963 -1743 1655 -698 1792 366 1517 -51 404 -1853 -1295 1652 -130 -1562 -1850 -582 1504 1888 822 -24 1807 9...

output:

663841

result:

ok 1 number(s): "663841"

Test #66:

score: 4
Accepted
time: 2ms
memory: 3980kb

input:

2000
56 -1667 -1636 -671 -1311 348 976 1381 -710 -477 -1301 756 -510 495 -1215 -278 1134 950 59 1739 -33 -839 -862 605 761 827 -1708 -1180 -607 1624 -120 -1198 624 -1237 -1874 1788 1005 -331 1266 -467 -1213 1736 -182 594 775 1209 -832 300 1188 -994 -191 -217 1360 -1907 71 436 1294 -590 913 -747 -629...

output:

667052

result:

ok 1 number(s): "667052"

Test #67:

score: 4
Accepted
time: 2ms
memory: 3980kb

input:

1999
-758656 -113741 -374719 7680 -227905 -201318 -200890 -84484 777096 -167712 -126972 -244117 835074 161027 923025 -224756 973701 36622 -913757 -920737 -976062 461264 147694 -162457 358437 -308202 385370 808271 -523703 -303454 -522131 -664739 -505124 306509 948216 948694 -467953 -768055 769796 486...

output:

675957

result:

ok 1 number(s): "675957"

Test #68:

score: 4
Accepted
time: 0ms
memory: 3700kb

input:

1
0

output:

0

result:

ok 1 number(s): "0"

Test #69:

score: 4
Accepted
time: 0ms
memory: 3608kb

input:

2
1000000000 999999999

output:

-1

result:

ok 1 number(s): "-1"

Test #70:

score: 4
Accepted
time: 0ms
memory: 3776kb

input:

2000
999998002 999998004 999998006 999998008 999998010 999998012 999998014 999998016 999998018 999998020 999998022 999998024 999998026 999998028 999998030 999998032 999998034 999998036 999998038 999998040 999998042 999998044 999998046 999998048 999998050 999998052 999998054 999998056 999998058 99999...

output:

999000

result:

ok 1 number(s): "999000"

Test #71:

score: 4
Accepted
time: 0ms
memory: 3752kb

input:

1999
-1000000000 -999012346 -998024692 -997037038 -996049384 -995061730 -994074076 -993086422 -992098768 -991111114 -990123460 -989135806 -988148152 -987160498 -986172844 -985185190 -984197536 -983209882 -982222228 -981234574 -980246920 -979259266 -978271612 -977283958 -976296304 -975308650 -9743209...

output:

0

result:

ok 1 number(s): "0"

Test #72:

score: 4
Accepted
time: 2ms
memory: 3712kb

input:

1999
1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 1942 1941 1940 ...

output:

1998

result:

ok 1 number(s): "1998"

Subtask #6:

score: 3
Accepted

Dependency #5:

100%
Accepted

Test #73:

score: 3
Accepted
time: 350ms
memory: 30980kb

input:

500000
-725 2759 -4173 -4473 4578 -5071 -7897 -7991 9738 -12600 17445 -18596 -20105 -21103 22718 26116 -26973 33169 -33830 34895 37480 -41216 -41665 43933 44687 45286 -46096 46958 47293 -50534 50597 -52520 -57079 57680 58680 -62109 63682 -64495 -64608 64674 -64848 -65420 67176 -74442 -76904 -77098 -...

output:

-1

result:

ok 1 number(s): "-1"

Test #74:

score: 3
Accepted
time: 524ms
memory: 31004kb

input:

500000
716212992 819699933 394255912 695521313 788446410 -466519569 476323400 812543029 724100006 -681244028 -306686799 216473950 496416101 636791486 302599115 190055737 -908659874 -407112922 733684038 -282369420 36611820 323272468 -755065727 -735846631 -22777612 905154351 -694170466 -726666701 7098...

output:

41671567967

result:

ok 1 number(s): "41671567967"

Test #75:

score: 3
Accepted
time: 518ms
memory: 31008kb

input:

500000
-207438 355273 -248123 -19764 185461 162549 -188348 52382 490160 -462312 -44831 -465995 -499994 -43101 -250302 46616 -299265 -249140 383722 -165273 213956 256256 -77000 360942 128116 -376727 -496619 100239 -264529 148062 -435402 -1754 -58897 -473213 469221 -155309 112961 -346627 -296763 -4248...

output:

41688628365

result:

ok 1 number(s): "41688628365"

Test #76:

score: 3
Accepted
time: 529ms
memory: 30768kb

input:

500000
446009 -206999 332464 418913 406238 362645 -398832 101718 476481 97209 16149 -32080 210518 98993 151207 150280 -465090 -481536 201273 -421543 126547 307562 390250 -352233 -297858 -139422 239902 347062 209365 -202318 -124062 209464 241668 -132664 323247 -258834 401172 -466622 -482207 197967 -4...

output:

41663196994

result:

ok 1 number(s): "41663196994"

Test #77:

score: 3
Accepted
time: 538ms
memory: 30772kb

input:

500000
326709 73487 -462901 -247992 -233542 51555 -292893 -379042 397932 -114616 482840 43601 -51534 -182229 -90626 8113 -350602 -9122 -113219 439803 177 370081 -374799 62644 -438795 350357 -148565 453075 -124099 15381 73618 75602 -490979 307811 225874 -65426 -87170 -163734 -392827 436432 402025 252...

output:

41656112780

result:

ok 1 number(s): "41656112780"

Test #78:

score: 3
Accepted
time: 519ms
memory: 30864kb

input:

499999
-6051333 -9732801 3294558 -6403019 -7017102 -9707201 -6061284 -5691041 6049033 8228170 3461230 9448399 5524454 -2197488 -7940006 -1350303 493335 -5456003 1090695 -2008109 -3237925 3617186 6998401 -3574218 999525 -426659 5779982 4786849 5638317 9889583 -6084486 -9252364 -5377778 8297232 545487...

output:

41726273087

result:

ok 1 number(s): "41726273087"

Test #79:

score: 3
Accepted
time: 1ms
memory: 3900kb

input:

1
1000000000

output:

0

result:

ok 1 number(s): "0"

Test #80:

score: 3
Accepted
time: 0ms
memory: 3900kb

input:

2
0 -1000000000

output:

-1

result:

ok 1 number(s): "-1"

Test #81:

score: 3
Accepted
time: 379ms
memory: 30868kb

input:

500000
999500002 999500004 999500006 999500008 999500010 999500012 999500014 999500016 999500018 999500020 999500022 999500024 999500026 999500028 999500030 999500032 999500034 999500036 999500038 999500040 999500042 999500044 999500046 999500048 999500050 999500052 999500054 999500056 999500058 999...

output:

62499750000

result:

ok 1 number(s): "62499750000"

Test #82:

score: 3
Accepted
time: 383ms
memory: 30988kb

input:

499999
-1000000000 -999996544 -999993088 -999989632 -999986176 -999982720 -999979264 -999975808 -999972352 -999968896 -999965440 -999961984 -999958528 -999955072 -999951616 -999948160 -999944704 -999941248 -999937792 -999934336 -999930880 -999927424 -999923968 -999920512 -999917056 -999913600 -99991...

output:

0

result:

ok 1 number(s): "0"

Test #83:

score: 3
Accepted
time: 339ms
memory: 31132kb

input:

499999
499998 499997 499996 499995 499994 499993 499992 499991 499990 499989 499988 499987 499986 499985 499984 499983 499982 499981 499980 499979 499978 499977 499976 499975 499974 499973 499972 499971 499970 499969 499968 499967 499966 499965 499964 499963 499962 499961 499960 499959 499958 499957...

output:

499998

result:

ok 1 number(s): "499998"

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%