Submission #22542

# Submission time Handle Problem Language Result Execution time Memory
22542 2017-04-30T05:26:06 Z 2000/4000(#946, 0xrgb) Unifying Values (KRIII5_UV) C++14
0 / 7
59 ms 1992 KB
#include <cstdio>
#include <map>

using namespace std;

const int MAXN = 10004;
const int P = 1000 * 1000 * 1000 + 7;
typedef long long lli;

int N;
lli S[MAXN];
lli D[MAXN];
map<lli,int> dp;

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) {
		scanf("%lld", &D[i]);
		S[i] += S[i - 1] + D[i];
	}

	int cnt = 0;
	for (int i = 1; i < N; ++i) {
		// 1 ~ i
		const lli st = S[i] - S[0];
		if (st == 0 || S[N] % st != 0) continue;

		dp.clear();
		dp[S[N]] = 1;
		for (int j = N - 1; j > i; --j) {
			auto it = dp.find(S[j] + st);
			if (it == dp.end()) continue;
			else dp[S[j]] = (dp[S[j]] + it->second) % P;
		}

		cnt = (cnt + dp[S[i] + st]) % P;
	}

	printf("%d\n", cnt);
	return 0;
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:16:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
UV.cpp:18:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &D[i]);
                       ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1332 KB Output is correct
2 Correct 0 ms 1332 KB Output is correct
3 Correct 0 ms 1332 KB Output is correct
4 Correct 9 ms 1992 KB Output is correct
5 Correct 9 ms 1992 KB Output is correct
6 Incorrect 0 ms 1332 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1464 KB Output is correct
2 Correct 13 ms 1464 KB Output is correct
3 Correct 3 ms 1464 KB Output is correct
4 Correct 59 ms 1332 KB Output is correct
5 Correct 43 ms 1332 KB Output is correct
6 Correct 33 ms 1332 KB Output is correct
7 Correct 29 ms 1464 KB Output is correct
8 Correct 9 ms 1464 KB Output is correct
9 Correct 9 ms 1332 KB Output is correct
10 Correct 0 ms 1332 KB Output is correct
11 Correct 0 ms 1332 KB Output is correct
12 Correct 0 ms 1332 KB Output is correct
13 Correct 0 ms 1332 KB Output is correct
14 Correct 0 ms 1332 KB Output is correct
15 Correct 3 ms 1332 KB Output is correct
16 Correct 0 ms 1332 KB Output is correct
17 Correct 9 ms 1992 KB Output is correct
18 Correct 9 ms 1992 KB Output is correct
19 Incorrect 0 ms 1332 KB Output isn't correct
20 Halted 0 ms 0 KB -