# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
257973 | 2020-08-05T06:48:52 Z | 임성재(#5053) | Toilets (JOI16_toilets) | C++17 | 2 ms | 3456 KB |
#include<bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(false); cin.tie(NULL) #define fi first #define se second #define pb push_back #define eb emplace_back #define em emplace #define all(v) (v).begin(), (v).end() #define pre(a) cout<<fixed; cout.precision(a) #define mp make_pair typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int inf = 1e9; const ll INF = 1e18; ll n, m; string s[100010]; int k[100010]; vector<pll> v; int dp[200010]; int main() { fast; cin >> n; cin >> m; ll cur = 0; for(int i=1; i<=m; i++) { cin >> s[i] >> k[i]; reverse(all(s[i])); int mx = 0; for(int j=0; j<s[i].size(); j++) { dp[j+1] = dp[j]; if(s[i][j] == 'F') dp[j+1]--; else dp[j+1]++; mx = max(mx, dp[j+1]); } v.eb(mx, dp[s[i].size()]); } if(v[0].se > 0) cout << "-1"; else cout << v[0].fi - 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3456 KB | Output is correct |
2 | Correct | 2 ms | 3456 KB | Output is correct |
3 | Incorrect | 2 ms | 3456 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3456 KB | Output is correct |
2 | Correct | 2 ms | 3456 KB | Output is correct |
3 | Incorrect | 2 ms | 3456 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3456 KB | Output is correct |
2 | Correct | 2 ms | 3456 KB | Output is correct |
3 | Incorrect | 2 ms | 3456 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |