# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140137 | 2019-08-02T07:36:33 Z | rdd6584 | Unifying Values (KRIII5_UV) | C++14 | 500 ms | 732 KB |
#include <cstdio> #include <algorithm> #include <memory.h> using namespace std; typedef long long ll; const int MOD = 1000000007; ll vec[10000]; int dp[10001]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &vec[i]); if (i) vec[i] += vec[i - 1]; } // i를 시작점으로 하는 배열 체크. ll ans = 0; for (int i = 0; i < n - 1; i++) { if (!vec[i] || vec[n - 1] % vec[i]) continue; if (vec[i] > 0 && vec[n - 1] < 0 || vec[i] < 0 && vec[n - 1] > 0) continue; memset(dp, 0, sizeof(dp)); dp[1] = 1; // printf("%lld //\n", vec[i]); for (int j = i + 1; j < n - 1; j++) { if (!vec[j] || vec[j] % vec[i]) continue; if (vec[i] > 0 && vec[j] < 0 || vec[i] < 0 && vec[j] > 0) continue; ll t = vec[j] / vec[i]; if (t <= 10000) dp[t] = (dp[t] + dp[t - 1]) % MOD; } ll t = vec[n - 1] / vec[i]; ans = (ans + dp[t - 1]) % MOD; // printf("%d : %lld\n", i, ans); } if (vec[n - 1] == 0) { ll sum = 1; for (int i = 0; i < n - 1; i++) if (vec[i] == 0) sum = sum * 2 % MOD; sum += MOD - 1; ans += sum; ans %= MOD; } printf("%lld", ans % MOD); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 6 ms | 376 KB | Output is correct |
5 | Correct | 6 ms | 504 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 7 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 516 KB | Output is correct |
9 | Correct | 5 ms | 380 KB | Output is correct |
10 | Correct | 34 ms | 492 KB | Output is correct |
11 | Correct | 27 ms | 504 KB | Output is correct |
12 | Correct | 43 ms | 376 KB | Output is correct |
13 | Correct | 10 ms | 504 KB | Output is correct |
14 | Correct | 8 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 9 ms | 504 KB | Output is correct |
17 | Correct | 7 ms | 636 KB | Output is correct |
18 | Correct | 45 ms | 516 KB | Output is correct |
19 | Execution timed out | 655 ms | 504 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 376 KB | Output is correct |
2 | Correct | 6 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 53 ms | 480 KB | Output is correct |
5 | Correct | 88 ms | 404 KB | Output is correct |
6 | Correct | 51 ms | 376 KB | Output is correct |
7 | Correct | 19 ms | 376 KB | Output is correct |
8 | Correct | 6 ms | 376 KB | Output is correct |
9 | Correct | 18 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 504 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 4 ms | 440 KB | Output is correct |
13 | Correct | 4 ms | 504 KB | Output is correct |
14 | Correct | 4 ms | 504 KB | Output is correct |
15 | Correct | 5 ms | 504 KB | Output is correct |
16 | Correct | 5 ms | 632 KB | Output is correct |
17 | Correct | 8 ms | 504 KB | Output is correct |
18 | Correct | 7 ms | 632 KB | Output is correct |
19 | Correct | 3 ms | 376 KB | Output is correct |
20 | Execution timed out | 625 ms | 732 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |