結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
nenuon
|
| 提出日時 | 2017-06-29 16:26:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,090 bytes |
| コンパイル時間 | 892 ms |
| コンパイル使用メモリ | 94,168 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-04 16:41:23 |
| 合計ジャッジ時間 | 1,586 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
int main(){
string s;
cin >> s;
int len = s.length();
ll ans = -10000000000;
// 先頭
FOR (i,0,len) {
ll num = 0;
ll sum = 0;
if (s[i] == '+' || s[i] == '-') continue;
if (s[(i + len - 1) % len] == '+' || s[(i + len - 1) % len] == '-') continue;
vector<ll> vll;
vector<char> vc;
FOR (j,0,len) {
int idx = (i + j) % len;
if (s[idx] == '+' || s[idx] == '-') {
vll.push_back(num);
vc.push_back(s[idx]);
num = 0;
} else {
num *= 10;
num += s[idx] - '0';
}
}
vll.push_back(num);
FOR(j,0,vll.size()-1) {
sum += vc[j] == '+' ? vll[j+1] : -vll[j+1];
}
ans = max(ans, sum + vll[0]);
}
cout << ans << endl;
return 0;
}
nenuon