結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2015-04-26 23:09:30 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 1,000 ms |
| コード長 | 1,533 bytes |
| コンパイル時間 | 1,117 ms |
| コンパイル使用メモリ | 106,880 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2024-07-05 01:19:11 |
| 合計ジャッジ時間 | 2,228 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));}
}
kuuso1