結果

問題 No.193 筒の数式
ユーザー dnishdnish
提出日時 2017-07-05 01:12:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 1,587 ms
コンパイル使用メモリ 165,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 16:22:55
合計ジャッジ時間 2,216 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define p(s) cout<<(s)<<endl
using namespace std;

int main(){
	string s;
	cin>>s;
	int ans=0;
	REP(i,0,s.size()){
		rotate(s.begin(),s.begin()+1,s.end());
		if(!isdigit(s[0])||!isdigit(s.back())) continue;
		int tmp=0;
		int mx=0;
		bool hugo=0;
		bool number=0;
		REP(j,0,s.size()){
			if(isdigit(s[j])){
				tmp*=10;
				tmp+=s[j]-'0';
				number=1;
			}else {
				if(number==0){
					mx=0;
					break;
				}else if(hugo==0)	mx+=tmp;
				else	mx-=tmp;
				tmp=0;
				if(s[j]=='+')	hugo=0;
				else if(s[j]=='-') hugo=1;

			}
		}
		if(number){
			if(hugo==0)	mx+=tmp;
			else	mx-=tmp;
		}
		ans=max(ans,mx);
	}
	p(ans);
	return 0;
}
0