답안 #370888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
370888 2021-02-25T01:34:12 Z R3KT Hacker (BOI15_hac) Java 11
컴파일 오류
0 ms 0 KB
import java.util.*;
import java.io.*;

public class HAC {

	// https://oj.uz/problem/view/BOI15_hac
	
	public static void main(String[] args) throws IOException, FileNotFoundException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("HAC"));

		int n = Integer.parseInt(in.readLine());
		long[] arr = new long[n];
		StringTokenizer st = new StringTokenizer(in.readLine());
		for (int i=0; i<n; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
		}
		
		ArrayList<Long> sums = new ArrayList<Long>();
		long sum=0;
		int k = (n+1)/2;
		for (int i=0; i<k; i++) {
			sum += arr[i];
		}
		sums.add(sum);
		
		for (int i=0; i<n-1; i++) {
			sum -= arr[i];
			sum += (arr[(i+k)%n]);
			sums.add(sum);
		}
		
		long ans=Math.min(sums.get(sums.size()-1), sums.get(0));
		for (int i=0; i<sums.size()-1; i++) {
			ans = Math.max(ans, Math.min(sums.get(i), sums.get(i+1)));
		}
		
		System.out.println(ans);
		

	}
}

Compilation message

hac.java:5: error: class HAC is public, should be declared in a file named HAC.java
public class HAC {
       ^
1 error