Submission #157038

# Submission time Handle Problem Language Result Execution time Memory
157038 2019-10-09T08:26:53 Z maruii Toilets (JOI16_toilets) C++14
0 / 100
2 ms 296 KB
#include <bits/stdc++.h>
using namespace std;

char S[200005];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int N, M; cin >> N >> M;
	long long y = 0, mny = 0;
	for (int i = 0; i < M; ++i) {
		int K;
		cin >> S + 1 >> K;
		vector<int> vec;
		long long sum = 0, mnSum = 0;
		for (int i = 1, t = 0; S[i]; ++i) {
			t++;
			if (S[i] != S[i + 1]) {
				sum += S[i] == 'F' ? t : -t;
				mnSum = min(mnSum, sum);
				t = 0;
			}
		}
		mny = min(mny, y + sum * (K - 1) + mnSum);
		y += K * sum;
	}
	if (y < 0) printf("-1");
	else printf("%lld", max(0ll, -mny - 1));
	return 0;
}

Compilation message

toilets.cpp: In function 'int main()':
toilets.cpp:12:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   cin >> S + 1 >> K;
          ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -