# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
257983 | 2020-08-05T07:17:51 Z | 송준혁(#5048) | Toilets (JOI16_toilets) | C++17 | 59 ms | 3708 KB |
#include <bits/stdc++.h> #define pb push_back #define lb lower_bound #define fi first #define se second #define mup(a,x) a=min(a,x) #define Mup(a,x) a=max(a,x) #define INF 1234567890 using namespace std; typedef long long LL; typedef pair<int,int> pii; int M; LL ans=-1, N, R[101010], P[101010]; char str[101010]; vector<char> S[101010]; vector<int> V; int main(){ scanf("%lld %d", &N, &M); scanf("%d", &R); for (int i=1; i<=M; i++){ scanf("%s", str); for (int j=0; str[j]; j++){ if (str[j] == 'M') P[i]++; S[i].pb(str[j]); } scanf("%d", &R[i]); } LL lo=0, hi=N; while (lo<=hi){ LL m=lo+hi>>1, t=0, s=0; int k=0; for (int i=1; i<=M; i++){ for (int j=0; j<S[i].size(); j++){ if (S[i][j] == 'F') V.pb(t+m); else s++, t++; while (k<V.size() && V[k] <= t){ s--, k++; if (s < -1) s=0; } } } while (k<V.size()){ s--, k++; if (s < -1) s=0; } V.clear(); if (s > 0) lo = m+1; else hi = m-1, ans = m; } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2720 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Correct | 2 ms | 2688 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 2 ms | 2688 KB | Output is correct |
9 | Correct | 2 ms | 2688 KB | Output is correct |
10 | Correct | 2 ms | 2688 KB | Output is correct |
11 | Correct | 2 ms | 2688 KB | Output is correct |
12 | Correct | 2 ms | 2688 KB | Output is correct |
13 | Correct | 2 ms | 2688 KB | Output is correct |
14 | Correct | 2 ms | 2720 KB | Output is correct |
15 | Correct | 2 ms | 2688 KB | Output is correct |
16 | Correct | 2 ms | 2688 KB | Output is correct |
17 | Correct | 2 ms | 2688 KB | Output is correct |
18 | Correct | 2 ms | 2688 KB | Output is correct |
19 | Correct | 2 ms | 2688 KB | Output is correct |
20 | Correct | 2 ms | 2688 KB | Output is correct |
21 | Correct | 2 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2720 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Correct | 2 ms | 2688 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 2 ms | 2688 KB | Output is correct |
9 | Correct | 2 ms | 2688 KB | Output is correct |
10 | Correct | 2 ms | 2688 KB | Output is correct |
11 | Correct | 2 ms | 2688 KB | Output is correct |
12 | Correct | 2 ms | 2688 KB | Output is correct |
13 | Correct | 2 ms | 2688 KB | Output is correct |
14 | Correct | 2 ms | 2720 KB | Output is correct |
15 | Correct | 2 ms | 2688 KB | Output is correct |
16 | Correct | 2 ms | 2688 KB | Output is correct |
17 | Correct | 2 ms | 2688 KB | Output is correct |
18 | Correct | 2 ms | 2688 KB | Output is correct |
19 | Correct | 2 ms | 2688 KB | Output is correct |
20 | Correct | 2 ms | 2688 KB | Output is correct |
21 | Correct | 2 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2688 KB | Output is correct |
23 | Correct | 35 ms | 3708 KB | Output is correct |
24 | Incorrect | 59 ms | 3708 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2720 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Correct | 2 ms | 2688 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 2 ms | 2688 KB | Output is correct |
9 | Correct | 2 ms | 2688 KB | Output is correct |
10 | Correct | 2 ms | 2688 KB | Output is correct |
11 | Correct | 2 ms | 2688 KB | Output is correct |
12 | Correct | 2 ms | 2688 KB | Output is correct |
13 | Correct | 2 ms | 2688 KB | Output is correct |
14 | Correct | 2 ms | 2720 KB | Output is correct |
15 | Correct | 2 ms | 2688 KB | Output is correct |
16 | Correct | 2 ms | 2688 KB | Output is correct |
17 | Correct | 2 ms | 2688 KB | Output is correct |
18 | Correct | 2 ms | 2688 KB | Output is correct |
19 | Correct | 2 ms | 2688 KB | Output is correct |
20 | Correct | 2 ms | 2688 KB | Output is correct |
21 | Correct | 2 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2688 KB | Output is correct |
23 | Correct | 35 ms | 3708 KB | Output is correct |
24 | Incorrect | 59 ms | 3708 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |