結果

問題 No.193 筒の数式
ユーザー utouto97utouto97
提出日時 2019-03-22 19:10:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,029 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 160,656 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 06:12:21
合計ジャッジ時間 2,233 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  string s;
  cin >> s;

  int n = s.size();
  s += s;

  int ans = 0;
  rep(i, n){
    if(s[i] == '+' or s[i] == '-' or s[n-1+i] == '+' or s[n-1+i] == '-') continue;

    int tmp = 0, t = 0, op = 0;
    rep(j, n){
      if('0' <= s[i+j] and s[i+j] < '9'){
        t = 10*t + s[i+j]-'0';
      }else{
        if(op == 0){
          tmp += t;
        }else{
          tmp -= t;
        }
        t = 0;
        op = s[i+j] == '-';
      }
    }

    if(op == 0){
      tmp += t;
    }else{
      tmp -= t;
    }

    ans = max(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}
0