結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-03-23 19:55:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 790 bytes |
| コンパイル時間 | 2,102 ms |
| コンパイル使用メモリ | 195,972 KB |
| 最終ジャッジ日時 | 2025-01-09 09:51:44 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 5 WA * 11 |
ソースコード
#include<bits/stdc++.h>
using lint=long long;
bool is_symbol(char c){return c=='+'||c=='-';}
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
std::string s;std::cin>>s;
lint n=s.length();
lint ans=0;
for(lint i=0;i<n;i++){
if(is_symbol(s.front())||is_symbol(s.back()))continue;
lint now=0;
for(lint j=0,x=0,neg=false;j<=n;j++){
if(j==n||is_symbol(s.at(j))){
now+=neg?-x:x;
x=0;
if(j<n)neg=s.at(j)=='-';
}else{
x=10*x+s.at(j)-'0';
}
}
if(ans<now)ans=now;
std::rotate(s.begin(),s.begin()+1,s.end());
}
std::cout<<ans<<'\n';
}
ngtkana