# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
258497 | arnold518 | Toilets (JOI16_toilets) | C++14 | 16 ms | 7184 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll MAXN = 1e18;
const int MAXM = 2e5;
ll N; int M;
string S[MAXM+10];
int K[MAXM+10];
int main()
{
int i, j;
//ios_base::sync_with_stdio(false);
cin>>N>>M;
for(i=1; i<=M; i++) cin>>S[i]>>K[i];
int t=0, k=1;
for(i=S[1].size()-1; i>=0; i--)
{
if(S[1][i]=='F') t--;
else t++;
k=max(k, t);
}
if(t>0) return !printf("-1\n");
printf("%d\n", k-1);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |