# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
192210 | dndhk | Toilets (JOI16_toilets) | C++14 | 35 ms | 5948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAX_N = 100000;
ll N;
int M;
string str[MAX_N+1];
ll num[MAX_N+1];
ll ans = 0;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin>>N>>M;
for(int i=1; i<=M; i++){
cin>>str[i];
cin>>num[i];
}
ll sum = 0;
for(int i=M; i>=1; i--){
ll S = 0;
for(int j=0; j<str[i].size(); j++){
if(str[i][j]=='M') S++;
else S--;
}
if(S>0){
sum+=(num[i]-1LL)*S;
}
for(int j=str[i].size()-1; j>=0; j--){
if(str[i][j]=='M') sum++;
else{
sum--;
ans = max(ans, sum);
}
}
if(S<=0){
sum+=(num[i]-1LL)*S;
}
}
if(sum>0) cout<<-1;
else cout<<ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |