結果
問題 | No.193 筒の数式 |
ユーザー |
![]() |
提出日時 | 2015-04-26 22:43:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 785 bytes |
コンパイル時間 | 438 ms |
コンパイル使用メモリ | 57,692 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 03:09:30 |
合計ジャッジ時間 | 1,100 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include <iostream> #include <algorithm> int main(){ std::string S; std::cin >> S; int L = S.size(); int mx = -2002002002; for(int i=0;i<L;i++){ if(!std::isdigit(S[i]) || !std::isdigit(S[(i+L-1)%L])){ continue; } int j = 0, result = 0; while(j < L && std::isdigit(S[(i+j)%L])){ result = result * 10 + S[(i+j)%L] - '0'; j++; } for(;j<L;){ int x = 0, sign = S[(i+j)%L]=='+' ? +1 : -1; j++; while(j < L && std::isdigit(S[(i+j)%L])){ x = x * 10 + S[(i+j)%L] - '0'; j++; } result += sign * x; } mx = std::max(mx, result); } std::cout << mx<< std::endl; }