結果
問題 | No.193 筒の数式 |
ユーザー |
![]() |
提出日時 | 2018-03-15 04:39:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 745 bytes |
コンパイル時間 | 628 ms |
コンパイル使用メモリ | 57,824 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-14 08:52:04 |
合計ジャッジ時間 | 1,517 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include<iostream> #include<string> using namespace std; int main(){ string S; int opi,len,buf,ans = -100000000; char op,c; cin >> S; len = S.length(); for(int i=0;i<len;i++){ c = S[len-1]; S = c + S.substr(0,len-1); if(S[0] == '+' || S[0] == '-' || S[len-1] == '+' || S[len-1] == '-') continue; buf = 0; opi = -1; op = '+'; for(int j=0;j<len;j++){ if(j != len-1 && S[j] != '+' && S[j] != '-') continue; if(op == '+') buf += stoi(S.substr(opi+1,j-opi)); else buf -= stoi(S.substr(opi+1,j-opi)); op = S[j]; opi = j; } if(ans < buf) ans = buf; } cout << ans << endl; return 0; }