結果

問題 No.193 筒の数式
ユーザー kyuridenamidakyuridenamida
提出日時 2015-04-26 22:15:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 968 bytes
コンパイル時間 2,466 ms
コンパイル使用メモリ 147,824 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 11:56:52
合計ジャッジ時間 2,099 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	string s;
	int x;
	long long ans = -1e18;

	cin >> s;
	for(int w = 0 ; w < 2 ; w++){
		for(int i = 0 ; i < 2*s.size() ; i++){
			try{
				if( s[0] == '+' || s[0] == '-' ) throw "";
				if( s[s.size()-1] == '+' || s[s.size()-1] == '-' ) throw "";
				
				int r = 0;
				int now;
				
				for(int j = 0 ; j+1 < s.size() ; j++){
					if( s[j] == s[j+1] && (s[j] == '+'||s[j]=='-') ) throw "";
					
				}
				int p = 1;
				//cout << s << endl;
				
				string t = s;
				t += "~";
				for(int j = 0 ; j < t.size() ; ){
					int now = 0;
					int k = j;
					while( t[k] >= '0' && t[k] <= '9' )
						now = now * 10 + t[k++] - '0';
					r += p * now;
					if( t[k++] == '-' ) p = -1;
					else p = 1;
					j = k;
				}
				ans = max(ans,r);
			}catch(const char *msg){
				
			}
			rotate(s.begin(),s.begin()+1,s.end());
		}
		//reverse(s.begin(),s.end());
	}
	cout << ans << endl;
	
}
0