結果

問題 No.193 筒の数式
ユーザー kuuso1kuuso1
提出日時 2015-04-26 23:09:30
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 1,533 bytes
コンパイル時間 5,189 ms
コンパイル使用メモリ 107,836 KB
実行使用メモリ 22,740 KB
最終ジャッジ日時 2023-09-18 09:33:25
合計ジャッジ時間 6,889 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
22,644 KB
testcase_01 AC 56 ms
20,612 KB
testcase_02 AC 55 ms
22,712 KB
testcase_03 AC 55 ms
20,580 KB
testcase_04 AC 54 ms
20,696 KB
testcase_05 AC 54 ms
20,644 KB
testcase_06 AC 54 ms
20,548 KB
testcase_07 AC 55 ms
20,692 KB
testcase_08 AC 55 ms
20,656 KB
testcase_09 AC 54 ms
20,552 KB
testcase_10 AC 55 ms
22,652 KB
testcase_11 AC 56 ms
22,740 KB
testcase_12 AC 55 ms
22,616 KB
testcase_13 AC 55 ms
20,596 KB
testcase_14 AC 57 ms
22,740 KB
testcase_15 AC 56 ms
22,588 KB
testcase_16 AC 55 ms
20,652 KB
testcase_17 AC 56 ms
20,692 KB
testcase_18 AC 56 ms
22,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long max=0;
		bool chk=false;
		String SS=S+S;
		for(int i=0;i<S.Length;i++){
			var T=SS.Substring(i,S.Length);
			if(T[0]=='-' || T[S.Length-1]=='-')continue;
			if(T[0]=='+' || T[S.Length-1]=='+')continue;
			long ans=cal(T);
			if(!chk){
				max=ans;chk=true;
			}
			max=Math.Max(ans,max);
		}
		Console.WriteLine(max);
	}
	
	long cal(String t){
		long tot=0;
		long sig=1;
		String buf="0";
		for(int i=0;i<t.Length;i++){
			if(t[i]<='9' && t[i]>='0'){
				buf+=t[i].ToString();
			}
			if(t[i]=='+'){
				tot+=sig*long.Parse(buf);
				buf="0";
				sig=1;
			}
			if(t[i]=='-'){
				tot+=sig*long.Parse(buf);
				buf="0";
				sig=-1;
			}
		}
		tot+=sig*long.Parse(buf);
		buf="0";
		sig=-1;
		return tot;
	
	}
	
	
	String S;
	public Sol(){
		S=rs();
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0