結果

問題 No.193 筒の数式
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-08 13:18:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 774 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 201,252 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 00:00:28
合計ジャッジ時間 3,262 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
    string s;
    cin>>s;
    int n=s.size();
    int mx=-100000000;
    for (int i=0;i<n;i++) {
        string t=s.substr(i)+s.substr(0,i);
        if (!isdigit(t[0])) continue;
        int ans=0;
        while (i<n && isdigit(t[i])) {
            ans=10*ans+t[i]-'0';
            i++;
        }
        while (i < n) {
            int sign=1;
            if (t[i]=='-') sign=-1;
            i++;
            if (i==n) goto invalid;
            int num=0;
            while (i<n && isdigit(t[i])) {
                num=10*num+t[i]-'0';
                i++;
            }
            ans+=num*sign;
        }
        mx=max(mx,ans);
        invalid:;
    }
    cout<<mx<<endl;
    return 0;
}
0