結果
問題 | No.193 筒の数式 |
ユーザー | kenkoooo |
提出日時 | 2015-04-26 22:47:22 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,119 bytes |
コンパイル時間 | 2,057 ms |
コンパイル使用メモリ | 74,524 KB |
実行使用メモリ | 56,212 KB |
最終ジャッジ日時 | 2023-09-18 12:18:29 |
合計ジャッジ時間 | 5,421 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 114 ms
55,916 KB |
testcase_01 | AC | 115 ms
55,696 KB |
testcase_02 | AC | 114 ms
55,892 KB |
testcase_03 | AC | 114 ms
55,532 KB |
testcase_04 | AC | 114 ms
55,632 KB |
testcase_05 | AC | 112 ms
56,000 KB |
testcase_06 | AC | 113 ms
55,548 KB |
testcase_07 | AC | 114 ms
56,060 KB |
testcase_08 | AC | 114 ms
55,556 KB |
testcase_09 | AC | 113 ms
55,504 KB |
testcase_10 | AC | 113 ms
55,884 KB |
testcase_11 | AC | 113 ms
56,212 KB |
testcase_12 | AC | 113 ms
55,720 KB |
testcase_13 | AC | 114 ms
55,796 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] line = sc.next().toCharArray(); sc.close(); long max = 0; for (int q = 0; q < line.length; q++) { if (Character.isDigit(line[0]) && Character.isDigit(line[line.length - 1])) { long sum = 0; boolean plus = true; StringBuilder sb = new StringBuilder(); for (int i = 0; i < line.length; i++) { if (Character.isDigit(line[i])) { sb.append(line[i]); } else { if (plus) { sum += Long.parseLong(sb.toString()); } else { sum -= Long.parseLong(sb.toString()); } sb.setLength(0); if (line[i] == '+') { plus = true; } else { plus = false; } } } if (plus) { sum += Long.parseLong(sb.toString()); } else { sum -= Long.parseLong(sb.toString()); } max = Math.max(max, sum); } char tmp = line[0]; for (int i = 1; i < line.length; i++) { line[i - 1] = line[i]; } line[line.length - 1] = tmp; } System.out.println(max); } }