Submission #53853

# Submission time Handle Problem Language Result Execution time Memory
53853 2018-07-01T09:48:39 Z ainta Toilets (JOI16_toilets) C++17
100 / 100
41 ms 5688 KB
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
long long L;
int n;
char p[201000];
struct point {
	string T;
	int s, M;
	long long K;
}w[101000];
long long ss;
int main() {
	int i, j;
	scanf("%lld%d", &L, &n);
	long long M = 0;
	for (i = 1; i <= n; i++) {
		scanf("%s", p);
		scanf("%lld", &w[i].K);
		w[i].s = w[i].M = 0;
		for (j = 0; p[j]; j++) {
			if (p[j] == 'F')w[i].s++;
			else w[i].s--;
			w[i].M = max(w[i].M, w[i].s);
		}
		M = max(M, max(ss + w[i].M, ss + w[i].s*(w[i].K - 1) + w[i].M));
		ss += w[i].s*w[i].K;
	}
	if (ss < 0) {
		puts("-1");
		return 0;
	}
	if (M < ss + 1)puts("0");
	else printf("%lld\n", M - (ss + 1));
}

Compilation message

toilets.cpp: In function 'int main()':
toilets.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%d", &L, &n);
  ~~~~~^~~~~~~~~~~~~~~~~~
toilets.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", p);
   ~~~~~^~~~~~~~~
toilets.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &w[i].K);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Output is correct
2 Correct 6 ms 5224 KB Output is correct
3 Correct 6 ms 5260 KB Output is correct
4 Correct 7 ms 5340 KB Output is correct
5 Correct 7 ms 5340 KB Output is correct
6 Correct 8 ms 5392 KB Output is correct
7 Correct 6 ms 5392 KB Output is correct
8 Correct 8 ms 5392 KB Output is correct
9 Correct 6 ms 5392 KB Output is correct
10 Correct 7 ms 5392 KB Output is correct
11 Correct 5 ms 5392 KB Output is correct
12 Correct 7 ms 5392 KB Output is correct
13 Correct 8 ms 5392 KB Output is correct
14 Correct 6 ms 5392 KB Output is correct
15 Correct 5 ms 5392 KB Output is correct
16 Correct 6 ms 5392 KB Output is correct
17 Correct 7 ms 5392 KB Output is correct
18 Correct 5 ms 5392 KB Output is correct
19 Correct 7 ms 5392 KB Output is correct
20 Correct 5 ms 5392 KB Output is correct
21 Correct 7 ms 5392 KB Output is correct
22 Correct 5 ms 5392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Output is correct
2 Correct 6 ms 5224 KB Output is correct
3 Correct 6 ms 5260 KB Output is correct
4 Correct 7 ms 5340 KB Output is correct
5 Correct 7 ms 5340 KB Output is correct
6 Correct 8 ms 5392 KB Output is correct
7 Correct 6 ms 5392 KB Output is correct
8 Correct 8 ms 5392 KB Output is correct
9 Correct 6 ms 5392 KB Output is correct
10 Correct 7 ms 5392 KB Output is correct
11 Correct 5 ms 5392 KB Output is correct
12 Correct 7 ms 5392 KB Output is correct
13 Correct 8 ms 5392 KB Output is correct
14 Correct 6 ms 5392 KB Output is correct
15 Correct 5 ms 5392 KB Output is correct
16 Correct 6 ms 5392 KB Output is correct
17 Correct 7 ms 5392 KB Output is correct
18 Correct 5 ms 5392 KB Output is correct
19 Correct 7 ms 5392 KB Output is correct
20 Correct 5 ms 5392 KB Output is correct
21 Correct 7 ms 5392 KB Output is correct
22 Correct 5 ms 5392 KB Output is correct
23 Correct 7 ms 5572 KB Output is correct
24 Correct 8 ms 5572 KB Output is correct
25 Correct 7 ms 5572 KB Output is correct
26 Correct 7 ms 5572 KB Output is correct
27 Correct 7 ms 5572 KB Output is correct
28 Correct 7 ms 5572 KB Output is correct
29 Correct 8 ms 5572 KB Output is correct
30 Correct 7 ms 5572 KB Output is correct
31 Correct 7 ms 5572 KB Output is correct
32 Correct 9 ms 5572 KB Output is correct
33 Correct 8 ms 5572 KB Output is correct
34 Correct 7 ms 5608 KB Output is correct
35 Correct 9 ms 5688 KB Output is correct
36 Correct 7 ms 5688 KB Output is correct
37 Correct 7 ms 5688 KB Output is correct
38 Correct 8 ms 5688 KB Output is correct
39 Correct 8 ms 5688 KB Output is correct
40 Correct 9 ms 5688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Output is correct
2 Correct 6 ms 5224 KB Output is correct
3 Correct 6 ms 5260 KB Output is correct
4 Correct 7 ms 5340 KB Output is correct
5 Correct 7 ms 5340 KB Output is correct
6 Correct 8 ms 5392 KB Output is correct
7 Correct 6 ms 5392 KB Output is correct
8 Correct 8 ms 5392 KB Output is correct
9 Correct 6 ms 5392 KB Output is correct
10 Correct 7 ms 5392 KB Output is correct
11 Correct 5 ms 5392 KB Output is correct
12 Correct 7 ms 5392 KB Output is correct
13 Correct 8 ms 5392 KB Output is correct
14 Correct 6 ms 5392 KB Output is correct
15 Correct 5 ms 5392 KB Output is correct
16 Correct 6 ms 5392 KB Output is correct
17 Correct 7 ms 5392 KB Output is correct
18 Correct 5 ms 5392 KB Output is correct
19 Correct 7 ms 5392 KB Output is correct
20 Correct 5 ms 5392 KB Output is correct
21 Correct 7 ms 5392 KB Output is correct
22 Correct 5 ms 5392 KB Output is correct
23 Correct 7 ms 5572 KB Output is correct
24 Correct 8 ms 5572 KB Output is correct
25 Correct 7 ms 5572 KB Output is correct
26 Correct 7 ms 5572 KB Output is correct
27 Correct 7 ms 5572 KB Output is correct
28 Correct 7 ms 5572 KB Output is correct
29 Correct 8 ms 5572 KB Output is correct
30 Correct 7 ms 5572 KB Output is correct
31 Correct 7 ms 5572 KB Output is correct
32 Correct 9 ms 5572 KB Output is correct
33 Correct 8 ms 5572 KB Output is correct
34 Correct 7 ms 5608 KB Output is correct
35 Correct 9 ms 5688 KB Output is correct
36 Correct 7 ms 5688 KB Output is correct
37 Correct 7 ms 5688 KB Output is correct
38 Correct 8 ms 5688 KB Output is correct
39 Correct 8 ms 5688 KB Output is correct
40 Correct 9 ms 5688 KB Output is correct
41 Correct 38 ms 5688 KB Output is correct
42 Correct 41 ms 5688 KB Output is correct
43 Correct 6 ms 5688 KB Output is correct
44 Correct 6 ms 5688 KB Output is correct
45 Correct 6 ms 5688 KB Output is correct
46 Correct 17 ms 5688 KB Output is correct
47 Correct 10 ms 5688 KB Output is correct
48 Correct 7 ms 5688 KB Output is correct
49 Correct 10 ms 5688 KB Output is correct
50 Correct 8 ms 5688 KB Output is correct
51 Correct 12 ms 5688 KB Output is correct
52 Correct 41 ms 5688 KB Output is correct
53 Correct 34 ms 5688 KB Output is correct
54 Correct 32 ms 5688 KB Output is correct
55 Correct 7 ms 5688 KB Output is correct
56 Correct 7 ms 5688 KB Output is correct