Nathan Coulas

CCC '17 S1 - Sum Game

ccc17s1 JAVA8 12 Feb, 2020 3.592s 3 points

Source Code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String args[]) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int n = Integer.parseInt(st.nextToken());
		
		int[] swift = new int[n];
		int[] sema = new int[n];
		int s1 = 0;
		int s2 = 0;
		int count = 0;
		
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++) {
			swift[i] = Integer.parseInt(st.nextToken());
		}
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++) {
			sema[i] = Integer.parseInt(st.nextToken());
		}
		
		for(int i = 0; i < n; i++) {
			
			s1 += sema[i];
			s2 += swift[i];
			
			if(s1 == s2) {
				count = i + 1;
			}
		}
		System.out.println(count);
		
	}
}