Submission #192203

#TimeUsernameProblemLanguageResultExecution timeMemory
192203dndhkToilets (JOI16_toilets)C++14
36 / 100
8 ms1628 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAX_N = 10000; ll N; int M; string str[MAX_N+1]; ll num[MAX_N+1]; ll ans = 0; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>N>>M; for(int i=1; i<=M; i++){ cin>>str[i]; cin>>num[i]; } ll sum = 0; for(int i=M; i>=1; i--){ ll S = 0; for(int j=0; j<str[i].size(); j++){ if(str[i][j]=='M') S++; else S--; } if(S>0){ sum+=(num[i]-1LL)*S; } for(int j=str[i].size()-1; j>=0; j--){ if(str[i][j]=='M') sum++; else{ sum--; ans = max(ans, sum); } } if(S<=0){ sum+=(num[i]-1LL)*S; } } if(sum>0) cout<<-1; else cout<<ans; return 0; }

Compilation message (stderr)

toilets.cpp: In function 'int main()':
toilets.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<str[i].size(); j++){
                ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...