結果

問題 No.999 てん vs. ほむ
ユーザー non3kzx
提出日時 2020-02-28 22:03:13
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 2,646 ms
コンパイル使用メモリ 73,296 KB
実行使用メモリ 63,704 KB
最終ジャッジ日時 2024-10-13 17:26:54
合計ジャッジ時間 6,911 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 6 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(reader.readLine());
		String[] str = reader.readLine().split(" ");
		int[] n = new int[2*N];
		for (int i = 0; i < 2*N; i++) {
			n[i] = Integer.parseInt(str[i]);
		}
		int max = 0;
		for (int b = 0; b < N; b++) {   //しきり
			int keep = 0;
			for (int a = 0; a < N; a++) {  //中の数
				if (a < b) {
					keep += n[2*a] - n[2*a+1];
				}
				else {
					keep += n[2*a+1] - n[2*a];
				}
			}
			if (keep > max) {
				max = keep;
			}
		}
		System.out.println(max);
	}
}
0