結果

問題 No.193 筒の数式
ユーザー spaciaspacia
提出日時 2016-01-09 11:23:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,056 bytes
コンパイル時間 2,350 ms
コンパイル使用メモリ 78,500 KB
実行使用メモリ 56,816 KB
最終ジャッジ日時 2023-10-19 16:54:37
合計ジャッジ時間 5,693 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
54,860 KB
testcase_01 AC 93 ms
54,492 KB
testcase_02 AC 93 ms
54,564 KB
testcase_03 AC 95 ms
55,092 KB
testcase_04 AC 96 ms
55,280 KB
testcase_05 AC 95 ms
54,596 KB
testcase_06 AC 93 ms
54,600 KB
testcase_07 AC 91 ms
54,628 KB
testcase_08 AC 100 ms
55,224 KB
testcase_09 AC 95 ms
54,904 KB
testcase_10 AC 93 ms
54,564 KB
testcase_11 AC 96 ms
54,840 KB
testcase_12 AC 107 ms
56,816 KB
testcase_13 AC 99 ms
55,364 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static int calc (String s) {
		int ret = 0 , work = 0 , i = 0 , len = s.length();
		boolean addFlg = true;
		while (i < len) {
			while (i < len && s.charAt(i) != '+' && s.charAt(i) != '-')
				work = work * 10 + (s.charAt(i++) - '0');
			ret = addFlg ? ret + work : ret - work;
			work = 0;
			if (i < len)
				addFlg = s.charAt(i++) == '+';
		}
		return ret;
	}
	
	public static int solve (String s) {
		int ret = 0;
		int len = s.length();
		for (int i = 0; i < len; i++) {
			String t = "";
			for (int j = 0; j < len; j++) {
				t += s.charAt((i + j) % len) + "";
			}
			if (!(t.charAt(0) + "").matches("[0-9]") || 
				!(t.charAt(len - 1) + "").matches("[0-9]")) {
					continue;
			}
			ret = Math.max(ret , calc(t));
		}
		return ret;
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		out(solve(br.readLine()));
	}
}
0