# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22747 | 버거킹 송죽SK점 우수고객 (#40) | Unifying Values (KRIII5_UV) | C++14 | 500 ms | 2708 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;
const int mod = 1e9+7;
int n, a[10005], s[10005], ans;
int pa[10005], pb[10005], dt[10005];
unordered_map<int, int> mp;
int solve (int idx) {
mp.clear();
for(int i=1;i<=n;i++) {
pa[i] = mp[s[i]-s[idx]];
pb[i] = mp[s[i]];
mp[s[i]] = i;
}
for(int i=0;i<idx;i++) dt[i] = 0;
dt[idx] = 1;
for(int i=idx+1;i<=n;i++) {
dt[i] = dt[pa[i]] + dt[pb[i]];
}
return dt[n];
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) {
scanf("%d",&a[i]);
s[i] = s[i-1] + a[i];
}
for(int i=1;i<=n;i++) {
ans = (ans + solve(i)) % mod;
}
printf("%d\n",(ans+mod-1)%mod);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |