# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647030 | borgar02 | Sum Zero (RMI20_sumzero) | C++17 | 319 ms | 18372 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
unsigned seed = chrono :: system_clock :: now().time_since_epoch().count();
mt19937 rng(seed);
using ll = long long;
const int N = 4e5 + 5;
ll c[N];
ll dp[N];
const ll P1 = (1ll << 20) - 1, P2 = ((1ll << 20) - 1) << 20, P3 = ((1ll << 20) - 1) << 40;
int main()
{
ios_base :: sync_with_stdio(false); cin.tie(0);
int n, q;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> c[i];
cin >> q;
partial_sum(c + 1, c + n + 1, c + 1);
set <ll> s;
dp[n + 1] = n + 1;
for(int i = n; i >= 0; i--) {
auto it = s.lower_bound(c[i] << 20);
if(it != s.end() && (*it >> 20) == c[i]) {
ll val = *it & P1;
dp[i] = min(val, dp[i + 1]);
s.erase(it);
} else dp[i] = dp[i + 1];
s.insert(c[i] << 20 | i);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |