Submission #1011301

#TimeUsernameProblemLanguageResultExecution timeMemory
1011301pccToilets (JOI16_toilets)C++17
36 / 100
6 ms3608 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long string s; vector<ll> pos[2]; ll N,M; int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>N>>M; if(N>1e6)return 0; for(int i = 0;i<M;i++){ string t; int c; cin>>t>>c; while(c--)s += t; } reverse(s.begin(),s.end()); pos[0].push_back(-1); for(int i = 0;i<s.size();i++){ pos[s[i] == 'M'].push_back(i); } while(pos[0].size()>pos[1].size())pos[0].pop_back(); if(pos[0].size()<pos[1].size()){ cout<<"-1\n"; return 0; } ll ans = 0; for(int i = 0;i<pos[0].size();i++){ auto it = upper_bound(pos[1].begin(),pos[1].end(),pos[0][i])-pos[1].begin(); ans = max(ans,1ll*it-i); } cout<<ans<<'\n'; return 0; }

Compilation message (stderr)

toilets.cpp: In function 'int main()':
toilets.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i = 0;i<s.size();i++){
      |                ~^~~~~~~~~
toilets.cpp:32:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i = 0;i<pos[0].size();i++){
      |                ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...