結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-02-05 00:18:40 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 820 bytes |
| コンパイル時間 | 7,488 ms |
| コンパイル使用メモリ | 274,020 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-02-05 00:18:49 |
| 合計ジャッジ時間 | 8,477 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
string s;
cin >> s;
int ans = -1e9;
rep(_, s.size()) {
if (isdigit(s.front()) && isdigit(s.back())) {
int now = 0, sum = 0;
bool plus = true;
for (char c : s) {
if (isdigit(c)) {
now = now * 10 + c - '0';
}
else {
sum += plus ? now : -now;
now = 0;
assert(c == '+' || c == '-');
plus = c == '+';
}
}
sum += plus ? now : -now;
ans = max(ans, sum);
}
s.push_back(s[0]);
s.erase(s.begin());
}
cout << ans << endl;
return 0;
}
a01sa01to