# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011568 |
2024-06-30T15:46:34 Z |
Pring |
Toilets (JOI16_toilets) |
C++17 |
|
14 ms |
5876 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
const int MXN = 100005;
ll n;
int m;
string s[MXN];
ll mul[MXN];
ll now = 0, ans = 0;
void DO(string &s, ll k) {
reverse(s.begin(), s.end());
ll d = 0, low = 0;
for (auto &i : s) {
if (i == 'F') d++;
else {
d--;
low = min(low, d);
}
}
low = min(low, d * (k - 1) + low);
d *= k;
ans = min(ans, now + low);
now += d;
}
void miku() {
cin >> n >> m;
FOR(i, 0, m) cin >> s[i] >> mul[i];
for (int i = m - 1; i >= 0; i--) {
DO(s[i], mul[i]);
}
if (now < 0) {
cout << -1 << '\n';
return;
}
cout << max(0LL, -ans - 1) << '\n';
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
miku();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4188 KB |
Output is correct |
2 |
Correct |
1 ms |
4188 KB |
Output is correct |
3 |
Correct |
1 ms |
4188 KB |
Output is correct |
4 |
Correct |
1 ms |
4188 KB |
Output is correct |
5 |
Correct |
1 ms |
4188 KB |
Output is correct |
6 |
Correct |
1 ms |
4188 KB |
Output is correct |
7 |
Correct |
1 ms |
4188 KB |
Output is correct |
8 |
Correct |
1 ms |
4188 KB |
Output is correct |
9 |
Correct |
1 ms |
4188 KB |
Output is correct |
10 |
Correct |
1 ms |
4188 KB |
Output is correct |
11 |
Correct |
1 ms |
4188 KB |
Output is correct |
12 |
Correct |
1 ms |
4184 KB |
Output is correct |
13 |
Correct |
1 ms |
4188 KB |
Output is correct |
14 |
Correct |
1 ms |
3932 KB |
Output is correct |
15 |
Correct |
1 ms |
4188 KB |
Output is correct |
16 |
Correct |
1 ms |
4188 KB |
Output is correct |
17 |
Correct |
1 ms |
4188 KB |
Output is correct |
18 |
Correct |
1 ms |
4188 KB |
Output is correct |
19 |
Correct |
1 ms |
4188 KB |
Output is correct |
20 |
Correct |
1 ms |
4188 KB |
Output is correct |
21 |
Correct |
1 ms |
4188 KB |
Output is correct |
22 |
Correct |
1 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4188 KB |
Output is correct |
2 |
Correct |
1 ms |
4188 KB |
Output is correct |
3 |
Correct |
1 ms |
4188 KB |
Output is correct |
4 |
Correct |
1 ms |
4188 KB |
Output is correct |
5 |
Correct |
1 ms |
4188 KB |
Output is correct |
6 |
Correct |
1 ms |
4188 KB |
Output is correct |
7 |
Correct |
1 ms |
4188 KB |
Output is correct |
8 |
Correct |
1 ms |
4188 KB |
Output is correct |
9 |
Correct |
1 ms |
4188 KB |
Output is correct |
10 |
Correct |
1 ms |
4188 KB |
Output is correct |
11 |
Correct |
1 ms |
4188 KB |
Output is correct |
12 |
Correct |
1 ms |
4184 KB |
Output is correct |
13 |
Correct |
1 ms |
4188 KB |
Output is correct |
14 |
Correct |
1 ms |
3932 KB |
Output is correct |
15 |
Correct |
1 ms |
4188 KB |
Output is correct |
16 |
Correct |
1 ms |
4188 KB |
Output is correct |
17 |
Correct |
1 ms |
4188 KB |
Output is correct |
18 |
Correct |
1 ms |
4188 KB |
Output is correct |
19 |
Correct |
1 ms |
4188 KB |
Output is correct |
20 |
Correct |
1 ms |
4188 KB |
Output is correct |
21 |
Correct |
1 ms |
4188 KB |
Output is correct |
22 |
Correct |
1 ms |
4188 KB |
Output is correct |
23 |
Correct |
2 ms |
4444 KB |
Output is correct |
24 |
Correct |
2 ms |
4524 KB |
Output is correct |
25 |
Correct |
2 ms |
4444 KB |
Output is correct |
26 |
Correct |
2 ms |
4440 KB |
Output is correct |
27 |
Correct |
2 ms |
4444 KB |
Output is correct |
28 |
Correct |
2 ms |
4444 KB |
Output is correct |
29 |
Correct |
2 ms |
4444 KB |
Output is correct |
30 |
Correct |
2 ms |
4444 KB |
Output is correct |
31 |
Correct |
2 ms |
4444 KB |
Output is correct |
32 |
Correct |
2 ms |
4444 KB |
Output is correct |
33 |
Correct |
2 ms |
4696 KB |
Output is correct |
34 |
Correct |
2 ms |
4444 KB |
Output is correct |
35 |
Correct |
2 ms |
4444 KB |
Output is correct |
36 |
Correct |
3 ms |
4444 KB |
Output is correct |
37 |
Correct |
2 ms |
4444 KB |
Output is correct |
38 |
Correct |
2 ms |
4444 KB |
Output is correct |
39 |
Correct |
2 ms |
4444 KB |
Output is correct |
40 |
Correct |
2 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4188 KB |
Output is correct |
2 |
Correct |
1 ms |
4188 KB |
Output is correct |
3 |
Correct |
1 ms |
4188 KB |
Output is correct |
4 |
Correct |
1 ms |
4188 KB |
Output is correct |
5 |
Correct |
1 ms |
4188 KB |
Output is correct |
6 |
Correct |
1 ms |
4188 KB |
Output is correct |
7 |
Correct |
1 ms |
4188 KB |
Output is correct |
8 |
Correct |
1 ms |
4188 KB |
Output is correct |
9 |
Correct |
1 ms |
4188 KB |
Output is correct |
10 |
Correct |
1 ms |
4188 KB |
Output is correct |
11 |
Correct |
1 ms |
4188 KB |
Output is correct |
12 |
Correct |
1 ms |
4184 KB |
Output is correct |
13 |
Correct |
1 ms |
4188 KB |
Output is correct |
14 |
Correct |
1 ms |
3932 KB |
Output is correct |
15 |
Correct |
1 ms |
4188 KB |
Output is correct |
16 |
Correct |
1 ms |
4188 KB |
Output is correct |
17 |
Correct |
1 ms |
4188 KB |
Output is correct |
18 |
Correct |
1 ms |
4188 KB |
Output is correct |
19 |
Correct |
1 ms |
4188 KB |
Output is correct |
20 |
Correct |
1 ms |
4188 KB |
Output is correct |
21 |
Correct |
1 ms |
4188 KB |
Output is correct |
22 |
Correct |
1 ms |
4188 KB |
Output is correct |
23 |
Correct |
2 ms |
4444 KB |
Output is correct |
24 |
Correct |
2 ms |
4524 KB |
Output is correct |
25 |
Correct |
2 ms |
4444 KB |
Output is correct |
26 |
Correct |
2 ms |
4440 KB |
Output is correct |
27 |
Correct |
2 ms |
4444 KB |
Output is correct |
28 |
Correct |
2 ms |
4444 KB |
Output is correct |
29 |
Correct |
2 ms |
4444 KB |
Output is correct |
30 |
Correct |
2 ms |
4444 KB |
Output is correct |
31 |
Correct |
2 ms |
4444 KB |
Output is correct |
32 |
Correct |
2 ms |
4444 KB |
Output is correct |
33 |
Correct |
2 ms |
4696 KB |
Output is correct |
34 |
Correct |
2 ms |
4444 KB |
Output is correct |
35 |
Correct |
2 ms |
4444 KB |
Output is correct |
36 |
Correct |
3 ms |
4444 KB |
Output is correct |
37 |
Correct |
2 ms |
4444 KB |
Output is correct |
38 |
Correct |
2 ms |
4444 KB |
Output is correct |
39 |
Correct |
2 ms |
4444 KB |
Output is correct |
40 |
Correct |
2 ms |
4444 KB |
Output is correct |
41 |
Correct |
14 ms |
5876 KB |
Output is correct |
42 |
Correct |
13 ms |
5856 KB |
Output is correct |
43 |
Correct |
2 ms |
4188 KB |
Output is correct |
44 |
Correct |
1 ms |
4188 KB |
Output is correct |
45 |
Correct |
1 ms |
4188 KB |
Output is correct |
46 |
Correct |
4 ms |
4700 KB |
Output is correct |
47 |
Correct |
2 ms |
4532 KB |
Output is correct |
48 |
Correct |
3 ms |
4524 KB |
Output is correct |
49 |
Correct |
3 ms |
4444 KB |
Output is correct |
50 |
Correct |
2 ms |
4580 KB |
Output is correct |
51 |
Correct |
4 ms |
4700 KB |
Output is correct |
52 |
Correct |
13 ms |
5464 KB |
Output is correct |
53 |
Correct |
11 ms |
5464 KB |
Output is correct |
54 |
Correct |
13 ms |
5212 KB |
Output is correct |
55 |
Correct |
2 ms |
4444 KB |
Output is correct |
56 |
Correct |
2 ms |
4444 KB |
Output is correct |