結果

問題 No.193 筒の数式
ユーザー ki_ki33ki_ki33
提出日時 2015-04-26 22:40:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,349 bytes
コンパイル時間 2,568 ms
コンパイル使用メモリ 84,388 KB
実行使用メモリ 55,812 KB
最終ジャッジ日時 2023-09-18 12:11:53
合計ジャッジ時間 5,836 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,396 KB
testcase_01 AC 122 ms
55,812 KB
testcase_02 AC 124 ms
55,412 KB
testcase_03 AC 122 ms
55,640 KB
testcase_04 AC 122 ms
55,756 KB
testcase_05 AC 120 ms
55,396 KB
testcase_06 AC 121 ms
55,436 KB
testcase_07 AC 125 ms
55,808 KB
testcase_08 AC 123 ms
55,752 KB
testcase_09 AC 123 ms
55,504 KB
testcase_10 AC 122 ms
55,500 KB
testcase_11 AC 123 ms
55,624 KB
testcase_12 AC 122 ms
55,504 KB
testcase_13 AC 124 ms
55,328 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListSet;

public class Main {
	public static final int C =  1000000007;
	static final int CY = 1000000000;

	public void calc() {
		StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);

		String s = sc.next();
		
		int ans = 0;
		//double ans = 0.0;

		for (int i=0; i < s.length(); i++) {
			String ns = "";
			ns += s.substring(i);
			ns += s.substring(0, i);
			ans = Math.max(ans, msd(ns));
		}
		

		System.out.println(ans);

	}

	int msd(String s) {
		if (s.endsWith("+") || s.endsWith("-") || s.startsWith("+") || s.startsWith("-")) {
			return -1;
		}
		int ret = 0;
		
		String[] ss = s.split("\\+");
		for (String str: ss) {
			int num = 0;
			String[] sst = str.split("-");
			for (int i=0; i < sst.length;i++) {
				if (i==0) {
					num += Integer.parseInt(sst[i]);
				}else {
					num -= Integer.parseInt(sst[i]);
				}
			}
			ret += num;
		}
		
		return ret;
		
	}


	public static void main(String[] args) {
		Main main = new Main();
		main.calc();

	}
}
0