# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22805 | 2017-04-30T07:35:19 Z | 버거킹 송죽SK점 우수고객(#1039, Namnamseo, khsoo01) | Unifying Values (KRIII5_UV) | C++14 | 500 ms | 2352 KB |
#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_zero (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]]) % mod; } return dt[n]; } bool valid (int A, int B) { return (A % B == 0 && A / B >= 1); } int solve (int idx) { if(idx == n) return 1; if(!valid(s[n], s[idx])) return 0; int t = s[n]/s[idx]; for(int i=0;i<=t;i++) dt[i] = 0; dt[1] = 1; for(int i=idx+1;i<n;i++) { if(!valid(s[i], s[idx])) continue; int tt = s[i]/s[idx]; if(tt >= t) continue; dt[tt] = (dt[tt] + dt[tt-1]) % mod; } return dt[t-1]; } 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 + (s[i] ? solve(i) : solve_zero(i))) % mod; } printf("%d\n",(ans+mod-1)%mod); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2220 KB | Output is correct |
2 | Correct | 0 ms | 2220 KB | Output is correct |
3 | Correct | 0 ms | 2220 KB | Output is correct |
4 | Correct | 0 ms | 2220 KB | Output is correct |
5 | Correct | 0 ms | 2220 KB | Output is correct |
6 | Execution timed out | 500 ms | 2220 KB | Execution timed out |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2352 KB | Output is correct |
2 | Correct | 6 ms | 2352 KB | Output is correct |
3 | Correct | 3 ms | 2352 KB | Output is correct |
4 | Correct | 43 ms | 2220 KB | Output is correct |
5 | Correct | 33 ms | 2220 KB | Output is correct |
6 | Correct | 89 ms | 2220 KB | Output is correct |
7 | Correct | 9 ms | 2352 KB | Output is correct |
8 | Correct | 3 ms | 2352 KB | Output is correct |
9 | Correct | 16 ms | 2220 KB | Output is correct |
10 | Correct | 0 ms | 2220 KB | Output is correct |
11 | Correct | 0 ms | 2220 KB | Output is correct |
12 | Correct | 0 ms | 2220 KB | Output is correct |
13 | Correct | 0 ms | 2220 KB | Output is correct |
14 | Correct | 3 ms | 2220 KB | Output is correct |
15 | Correct | 3 ms | 2220 KB | Output is correct |
16 | Correct | 3 ms | 2220 KB | Output is correct |
17 | Incorrect | 0 ms | 2220 KB | Output isn't correct |
18 | Halted | 0 ms | 0 KB | - |