답안 #257983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257983 2020-08-05T07:17:51 Z 송준혁(#5048) Toilets (JOI16_toilets) C++17
14 / 100
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

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]);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -