結果

問題 No.193 筒の数式
ユーザー she11codeshe11code
提出日時 2015-05-06 06:39:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,393 bytes
コンパイル時間 1,373 ms
コンパイル使用メモリ 149,036 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-19 07:08:34
合計ジャッジ時間 2,305 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int parse(string s) {
    int b = 0;
    int sign = 1;
    int res = 0;
    REP(i, s.length()) {
        if (s[i] == '+' || s[i] == '-') {
            res += sign * stoi(s.substr(b, i));
            sign = (s[i] == '-' ? -1 : 1);
            b = i+1;
        }
    }
    res += sign * stoi(s.substr(b, s.length()));
    return res;
}

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

    int ma = 0;
    REP(i, s.length()) {
        stringstream ss;
        FOR(j, i, s.length()) ss << s[j];
        FOR(j, 0, i) ss << s[j];

        string e = ss.str();
        int l = e.length()-1;
        if (e[0] == '+' || e[0] == '-' || e[l] == '+' || e[l] == '-') {
            continue;
        }
        ma = max(ma, parse(e));
    }
    cout << ma << endl;
}
0