summaryrefslogtreecommitdiffstats
path: root/šola/p2/dn/DN04a_63230317.c
blob: 9c1c1b1c67d16a4f49730f9544c25ecc98dfb878 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <stdbool.h>
int main (void) {
	int n;
	scanf("%d", &n);
	int a[2*n];
	unsigned int lsum = 0;
	unsigned int rsum = 0;
	for (int i = 0; i < 2*n; i++)
		scanf("%d", &a[i]);
	for (int k = 0;; k++) {
		if (lsum == rsum) {
			bool pravilno = true;
			for (int j = 0; j < n; j++) {
				// fprintf(stderr, "%d\t%d\t%d\t%d\n", j, a[j], (n+(n-k+j) % n), a[(n+(n-k+j) % n)]);
				if (a[j] == a[n+(n-k+j) % n])
					continue;
				pravilno = false;
				break;
			}
			if (pravilno) {
				printf("%d\n", k);
				break;
			}
		}
		lsum += a[k];
		rsum += a[2*n-1-k];

	}
}