結果
| 問題 | 
                            No.193 筒の数式
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ngtkana
                         | 
                    
| 提出日時 | 2020-03-23 19:59:10 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 781 bytes | 
| コンパイル時間 | 2,148 ms | 
| コンパイル使用メモリ | 195,748 KB | 
| 最終ジャッジ日時 | 2025-01-09 09:51:56 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 11 WA * 5 | 
ソースコード
#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++,std::rotate(s.begin(),s.begin()+1,s.end())){
        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::cout<<ans<<'\n';
}
            
            
            
        
            
ngtkana