結果
問題 | No.193 筒の数式 |
ユーザー | takayuta1999 |
提出日時 | 2015-04-26 22:22:21 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 847 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 43,004 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-18 11:59:05 |
合計ジャッジ時間 | 1,114 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 2 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 | 1 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 1 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,380 KB |
testcase_15 | AC | 1 ms
4,380 KB |
testcase_16 | AC | 1 ms
4,376 KB |
testcase_17 | AC | 1 ms
4,376 KB |
testcase_18 | AC | 1 ms
4,380 KB |
ソースコード
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #define SIZE 12 #define INF 1000000000000LL using namespace std; typedef long long int ll; char str[SIZE]; int main() { scanf("%s",&str); int n=strlen(str); ll ret=-INF; for(int i=0;i<n;i++) { if(str[i]=='-'||str[i]=='+') continue; if(str[(i+n-1)%n]=='-'||str[(i+n-1)%n]=='+') continue; ll calc=0; int now=i; while(str[now]!='-'&&str[now]!='+') { calc*=10LL; calc+=str[now]-'0'; now=(now+1)%n; if(now==i) break; } while(now!=i) { bool up=str[now]=='+'; now=(now+1)%n; ll vl=0; while(str[now]!='-'&&str[now]!='+') { vl*=10LL; vl+=str[now]-'0'; now=(now+1)%n; if(now==i) break; } if(up) calc+=vl; else calc-=vl; } ret=max(ret,calc); } printf("%lld\n",ret); return 0; }