結果

問題 No.193 筒の数式
ユーザー ki_ki33ki_ki33
提出日時 2015-04-26 22:55:38
言語 Java19
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 1,477 bytes
コンパイル時間 2,673 ms
コンパイル使用メモリ 92,872 KB
実行使用メモリ 55,928 KB
最終ジャッジ日時 2023-09-18 12:22:00
合計ジャッジ時間 5,937 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,288 KB
testcase_01 AC 123 ms
55,560 KB
testcase_02 AC 121 ms
55,332 KB
testcase_03 AC 121 ms
55,656 KB
testcase_04 AC 122 ms
55,660 KB
testcase_05 AC 122 ms
55,928 KB
testcase_06 AC 121 ms
55,584 KB
testcase_07 AC 124 ms
55,620 KB
testcase_08 AC 126 ms
55,680 KB
testcase_09 AC 124 ms
55,820 KB
testcase_10 AC 122 ms
55,812 KB
testcase_11 AC 123 ms
55,540 KB
testcase_12 AC 123 ms
55,824 KB
testcase_13 AC 125 ms
55,640 KB
testcase_14 AC 123 ms
55,400 KB
testcase_15 AC 123 ms
55,556 KB
testcase_16 AC 122 ms
55,688 KB
testcase_17 AC 123 ms
55,552 KB
testcase_18 AC 124 ms
55,528 KB
権限があれば一括ダウンロードができます

ソースコード

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 = Integer.MIN_VALUE;
		//double ans = 0.0;

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

		System.out.println(ans);

	}

	int msd(String s) {
		if (s.endsWith("+") || s.endsWith("-") || s.startsWith("+") || s.startsWith("-")) {
			return Integer.MIN_VALUE;
		}
		int ret = 0;
		
		String[] ss = s.split("\\+");
		for (String str: ss) {
			//System.out.println(str);
			int num = 0;
			String[] sst = str.split("-");
			for (int i=0; i < sst.length;i++) {
				//System.out.println(sst[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