Submission #157032

#TimeUsernameProblemLanguageResultExecution timeMemory
157032jhwest2Toilets (JOI16_toilets)C++14
36 / 100
17 ms2044 KiB
#include <bits/stdc++.h> #define va first #define vb second using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int N, M, K, cnt; string s; vector<int> A, B; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> N >> M; cin >> s >> K; for (int i=0; i<s.size(); i++) { if (s[i] == 'F') ++cnt; else A.push_back(cnt); } if (A.size() > N) { cout << -1; return 0; } for (int i=0; i<A.size(); i++) { B.push_back(min(A[i], 2*(N-(int)A.size())+1+i)); } int ans=0, ap=0, bp=0; for (int i=1; i<=2*N; i++) { while (ap!=A.size() && A[ap]<i) ++ap; while (bp!=B.size() && B[bp]<i) ++bp; ans = max(ans, bp-ap); } cout << ans; }

Compilation message (stderr)

toilets.cpp: In function 'int main()':
toilets.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<s.size(); i++) {
                ~^~~~~~~~~
toilets.cpp:23:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (A.size() > N) { cout << -1; return 0; }
      ~~~~~~~~~^~~
toilets.cpp:25:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<A.size(); i++) {
                ~^~~~~~~~~
toilets.cpp:31:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (ap!=A.size() && A[ap]<i) ++ap;
          ~~^~~~~~~~~~
toilets.cpp:32:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (bp!=B.size() && B[bp]<i) ++bp;
          ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...