Submission #257984

# Submission time Handle Problem Language Result Execution time Memory
257984 2020-08-05T07:19:04 Z 송준혁(#5048) Toilets (JOI16_toilets) C++17
36 / 100
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

toilets.cpp: In function 'int main()':
toilets.cpp:21:16: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'LL (*)[101010] {aka long long int (*)[101010]}' [-Wformat=]
  scanf("%d", &R);
              ~~^
toilets.cpp:28:20: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'LL* {aka long long int*}' [-Wformat=]
   scanf("%d", &R[i]);
               ~~~~~^
toilets.cpp:32:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   LL m=lo+hi>>1, t=0, s=0;
        ~~^~~
toilets.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int j=0; j<S[i].size(); j++){
                  ~^~~~~~~~~~~~
toilets.cpp:38:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (k<V.size() && V[k] <= t){
            ~^~~~~~~~~
toilets.cpp:44:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (k<V.size()){
          ~^~~~~~~~~
toilets.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~~~~
toilets.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &R);
  ~~~~~^~~~~~~~~~
toilets.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", str);
   ~~~~~^~~~~~~~~~~
toilets.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &R[i]);
   ~~~~~^~~~~~~~~~~~~
# 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 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
# 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 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
# 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 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 -