Submission #3050281
Source Code Expand
https:/#include<iostream> using ll = long long; using namespace std; int main(){ string str; cin>>str; int cnt=0,ans=1; for(int i=0;i<str.size();i++){ if(str[i]=='2') cnt++; else cnt--; ans = max(ans,cnt); if(cnt<0){ cout << "-1\n"; return 0; } } if(cnt!=0){ cout << "-1\n"; return 0; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - 2525文字列分解 |
User | thash |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 457 Byte |
Status | CE |
Compile Error
./Main.cpp:1:8: error: stray ‘#’ in program https:/#include<iostream> ^ ./Main.cpp:1:1: error: ‘https’ does not name a type https:/#include<iostream> ^ ./Main.cpp: In function ‘int main()’: ./Main.cpp:5:5: error: ‘string’ was not declared in this scope string str; ^ ./Main.cpp:6:5: error: ‘cin’ was not declared in this scope cin>>str; ^ ./Main.cpp:6:10: error: ‘str’ was not declared in this scope cin>>str; ^ ./Main.cpp:11:26: error: ‘max’ was not declared in this scope ans = max(ans,cnt); ^ ./Main.cpp:13:13: error: ‘cout’ was not declared in this scope cout << "-1\n"; ^ ./Main.cpp:18:9: error: ‘cout’ was not declared in this scope cout << "-1\n"; ^ ./Main.cpp:21:5: error: ‘cout’ was not declared in this scope cout << ans << endl; ^ ./Main.cpp:21:20: error: ‘endl’ was not declared in this scope cout << ans << endl; ^