Submission #647025

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
6470252022-10-01 12:16:01borgar02Sum Zero (RMI20_sumzero)C++17
61 / 100
388 ms22156 KiB
#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);
map <ll, int> m;
dp[n + 1] = n + 1;
for(int i = n; i >= 0; i--) {
dp[i] = (m.count(c[i]) ? min(m[c[i]], (int)dp[i + 1]) : dp[i + 1]);
m[c[i]] = i;
}
m.clear();
for(ll i = 1, l, r; i <= q; i++) {
cin >> l >> r;
l--;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...