結果

問題 No.193 筒の数式
ユーザー sekiya9311sekiya9311
提出日時 2016-06-20 09:34:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,784 bytes
コンパイル時間 1,073 ms
コンパイル使用メモリ 102,120 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-11 05:25:43
合計ジャッジ時間 1,729 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())
#define MP(a,b) make_pair(a,b)
#define FORE(a,b) for(auto &&a:b)
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
int main(void){
string s; cin>>s;
char b;
int mn=INT_MIN;
int n[2];
REP(i,s.size()){
//DEBUG(s);
int id=0,bn=0; unsigned char p=0; //1:+ 2:-
int buf=0;
if((!('0'<=s[0]&&s[0]<='9'))||(!('0'<=s[s.size()-1]&&s[s.size()-1]<='9'))){
b=s[0]; s.erase(s.begin());
s.push_back(b);
continue;
}
REP(i,2) n[i]=0;
REP(j,s.size()){
if(!('0'<=s[j]&&s[j]<='9')){
if(!p){
bn=n[id];
}else{
(p==1)?bn+=n[id]:bn-=n[id];
}
(s[j]=='+')?p=1:p=2;
n[id]=0;
id=(id+1)%2;
}else{
n[id]*=10; n[id]+=(s[j]-'0');
}
}
(p==1)?bn+=n[id]:bn-=n[id];
mn=max(mn,bn);
b=s[0]; s.erase(s.begin());
s.push_back(b);
}
cout<<mn<<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0