Submission #103419


Source Code Expand

import java.util.Scanner;

public class M {

	static int N,M;
	static int[] a;
	static long[] sum;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		N=sc.nextInt();
		M=sc.nextInt();
		a=new int[N];
		sum=new long[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
			if(i<N/2){
				sum[0]+=a[i];
			}
		}
		int r = N/2,l = 0;
		for(int i=1;i<N;i++){
			r = (r-1+N)%N;
			l = (l-1+N)%N;
			sum[i] = sum[i-1]-a[r]+a[l];
		}
		int now=0;
		long ans=sum[0];
		for(int i=0;i<M;i++){
			int k = sc.nextInt();
			now = (now-(k-1)+N)%N;
			ans=Math.max(ans, sum[now]);
		}
		System.out.println(ans);
	}

}

Submission Info

Submission Time
Task J - Very Intellectual Card Game
User haruki57
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 669 Byte
Status CE

Compile Error

./Main.java:3: error: class M is public, should be declared in a file named M.java
public class M {
       ^
1 error