Submission #1011352

#TimeUsernameProblemLanguageResultExecution timeMemory
1011352pccTelegraph (JOI16_telegraph)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long string s; vector<ll> pos[2]; ll N,M; int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>N>>M; if(N>1e6)return 0; for(int i = 0;i<M;i++){ string t; int c; cin>>t>>c; while(c--)s += t; } reverse(s.begin(),s.end()); ll sum = 0,ans = 0; for(auto &i:s){ if(i == 'F'){ sum--; ans = max(ans,sum); } else sum++; } if(sum>0)cout<<"-1\n"; else cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...