結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
IJMP320
|
| 提出日時 | 2015-04-26 23:01:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,251 bytes |
| コンパイル時間 | 1,370 ms |
| コンパイル使用メモリ | 168,572 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 00:50:44 |
| 合計ジャッジ時間 | 2,218 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 9 WA * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define FOR(i,a,n) for(int i=a;i<(int)(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define MP(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define F first
#define S second
const int INF = 2000000000;
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
struct P{int x;int y;P(int X=0,int Y=0){x=X;y=Y;}};
int main() {
string S;
cin >> S;
int len = S.size();
S=S+S;
int ans = 0;
for(int i=0; i<len; i++) {
if(S[i]=='+' || S[i]=='-' || S[i+len-1]=='+' || S[i+len-1]=='-') continue;
string tmp;
queue<int> num;
queue<char> en;
FOR(j,i,i+len) {
if(S[j]=='+') {
int n = atoi(tmp.c_str());
num.push(n);
tmp="";
en.push('+');
}
else if(S[j]=='-') {
int n = atoi(tmp.c_str());
n*=-1;
num.push(n);
tmp="";
en.push('-');
}
tmp += S[j];
}
int n = atoi(tmp.c_str());
num.push(n);
int t=num.front(); num.pop();;
while(true) {
int b = num.front(); num.pop();
char c = en.front(); en.pop();
if(c=='+') t += b;
else if(c=='-') t -= b;
if(num.empty()) break;
}
ans = max(ans, t);
}
cout << ans << endl;
return 0;
}
IJMP320