# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
257984 | 2020-08-05T07:19:04 Z | 송준혁(#5048) | Toilets (JOI16_toilets) | C++17 | 68 ms | 7800 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[202020]; 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
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 2688 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 | 1 ms | 2688 KB | Output is correct |
13 | Correct | 2 ms | 2688 KB | Output is correct |
14 | Correct | 2 ms | 2688 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 | 1 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 2688 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 | 1 ms | 2688 KB | Output is correct |
13 | Correct | 2 ms | 2688 KB | Output is correct |
14 | Correct | 2 ms | 2688 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 | 1 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2688 KB | Output is correct |
23 | Correct | 34 ms | 3708 KB | Output is correct |
24 | Correct | 46 ms | 3708 KB | Output is correct |
25 | Correct | 43 ms | 3708 KB | Output is correct |
26 | Correct | 21 ms | 4216 KB | Output is correct |
27 | Correct | 15 ms | 3328 KB | Output is correct |
28 | Correct | 43 ms | 3708 KB | Output is correct |
29 | Correct | 38 ms | 4216 KB | Output is correct |
30 | Correct | 34 ms | 3708 KB | Output is correct |
31 | Correct | 41 ms | 3708 KB | Output is correct |
32 | Correct | 45 ms | 3708 KB | Output is correct |
33 | Correct | 21 ms | 3328 KB | Output is correct |
34 | Correct | 27 ms | 4216 KB | Output is correct |
35 | Correct | 51 ms | 3708 KB | Output is correct |
36 | Correct | 49 ms | 3708 KB | Output is correct |
37 | Correct | 21 ms | 4216 KB | Output is correct |
38 | Correct | 34 ms | 3708 KB | Output is correct |
39 | Correct | 44 ms | 3708 KB | Output is correct |
40 | Correct | 38 ms | 4216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 2688 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 | 1 ms | 2688 KB | Output is correct |
13 | Correct | 2 ms | 2688 KB | Output is correct |
14 | Correct | 2 ms | 2688 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 | 1 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2688 KB | Output is correct |
23 | Correct | 34 ms | 3708 KB | Output is correct |
24 | Correct | 46 ms | 3708 KB | Output is correct |
25 | Correct | 43 ms | 3708 KB | Output is correct |
26 | Correct | 21 ms | 4216 KB | Output is correct |
27 | Correct | 15 ms | 3328 KB | Output is correct |
28 | Correct | 43 ms | 3708 KB | Output is correct |
29 | Correct | 38 ms | 4216 KB | Output is correct |
30 | Correct | 34 ms | 3708 KB | Output is correct |
31 | Correct | 41 ms | 3708 KB | Output is correct |
32 | Correct | 45 ms | 3708 KB | Output is correct |
33 | Correct | 21 ms | 3328 KB | Output is correct |
34 | Correct | 27 ms | 4216 KB | Output is correct |
35 | Correct | 51 ms | 3708 KB | Output is correct |
36 | Correct | 49 ms | 3708 KB | Output is correct |
37 | Correct | 21 ms | 4216 KB | Output is correct |
38 | Correct | 34 ms | 3708 KB | Output is correct |
39 | Correct | 44 ms | 3708 KB | Output is correct |
40 | Correct | 38 ms | 4216 KB | Output is correct |
41 | Incorrect | 68 ms | 7800 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |