結果

問題 No.193 筒の数式
ユーザー negi_magnetnegi_magnet
提出日時 2015-04-28 19:01:04
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 62,596 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-18 14:06:16
合計ジャッジ時間 1,425 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

int main() {
	string in;
	cin >> in;
	ll res = 0;
	for(int s=0; s<in.length(); s++) {
		if(in[s]=='+' || in[s]=='-' || in[(s+in.length()-1)%in.length()]=='+' || in[(s+in.length()-1)%in.length()]=='-') {
			continue;
		}
		int i = s;
		ll op = 1;
		ll sum = 0;
		ll num = 0;
		do {
			if(in[i]=='+') {
				sum += op * num;
				op = 1;
				num = 0;
			} else if(in[i]=='-') {
				sum += op * num;
				op = -1;
				num = 0;
			} else {
				num = num*10 + (in[i]-'0');
			}
			i = (i+1) % in.length();
		}while(i!=s);
		sum += op * num;
		res = max(res, sum);
	}
	cout << res << endl;
	return 0;
}
0