結果

問題 No.193 筒の数式
ユーザー kpinkcatkpinkcat
提出日時 2023-11-05 17:19:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,269 bytes
コンパイル時間 2,844 ms
コンパイル使用メモリ 209,552 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-11-05 17:19:27
合計ジャッジ時間 3,835 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;


int main(){
    string s;
    cin >> s;
    deque<string> dq1;
    for (int i = 0; i < s.size(); i++){
        string f, b;
        f = s.substr(0, i);
        b = s.substr(i);
        b += f;
        if (b[0] != '+' && b[0] != '-' && b[b.size()-1] != '+' && b[b.size()-1] != '-') dq1.push_back(b);
    }
    int ans = 0;
    while (!dq1.empty()) {
        string num = "";
        string ss = dq1.front();
        char op = '\0';
        int tmp = 0;
        for (int i = 0; i < ss.size(); i++){
            if (ss[i] >= '0' && ss[i] <= '9') num += ss[i];
            else {
                if (op == '\0' || op == '+') tmp += stoi(num);
                else tmp -= stoi(num);
                num = "";
                if (ss[i] == '+') op = '+';
                else op = '-';
            }
            if (i == ss.size() - 1){
                if (op == '+') tmp += stoi(num);
                else tmp -= stoi(num);
            }
        }
        ans = max(ans, tmp);
        dq1.pop_front();
    }
    cout << ans << endl;
}
0