답안 #696777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
696777 2023-02-07T08:38:25 Z Cross_Ratio Toilets (JOI16_toilets) C++14
36 / 100
24 ms 5836 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
string s[100005];
int A[100005];
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    int M;
    cin >> N >> M;
    int i, j;
    for(i=0;i<M;i++) cin >> s[i] >> A[i];
    int ma = 0;
    int sum = 0;
    for(i=M-1;i>=0;i--) {
        int cnt = 0;
        int ma2 = 0;
        for(j=s[i].length()-1;j>=0;j--) {
            if(s[i][j]=='M') cnt++;
            else cnt--;
            ma2 = max(ma2, cnt);
        }
        if(cnt<=0) ma = max(ma, sum + ma2);
        else ma = max(ma, sum + cnt + ma2 + (A[i]-1) * cnt);
        sum += cnt * A[i];
    }
    cout << (sum <= 0 ? max(0LL,ma-1) : -1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
9 Correct 2 ms 3412 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 2 ms 3412 KB Output is correct
12 Correct 2 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 3 ms 3412 KB Output is correct
15 Correct 3 ms 3412 KB Output is correct
16 Correct 3 ms 3412 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 2 ms 3412 KB Output is correct
21 Correct 2 ms 3412 KB Output is correct
22 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
9 Correct 2 ms 3412 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 2 ms 3412 KB Output is correct
12 Correct 2 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 3 ms 3412 KB Output is correct
15 Correct 3 ms 3412 KB Output is correct
16 Correct 3 ms 3412 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 2 ms 3412 KB Output is correct
21 Correct 2 ms 3412 KB Output is correct
22 Correct 2 ms 3412 KB Output is correct
23 Correct 3 ms 3796 KB Output is correct
24 Correct 4 ms 3796 KB Output is correct
25 Correct 3 ms 3796 KB Output is correct
26 Correct 3 ms 3796 KB Output is correct
27 Correct 2 ms 3796 KB Output is correct
28 Correct 3 ms 3796 KB Output is correct
29 Correct 3 ms 3796 KB Output is correct
30 Correct 3 ms 3796 KB Output is correct
31 Correct 3 ms 3796 KB Output is correct
32 Correct 3 ms 3796 KB Output is correct
33 Correct 2 ms 3796 KB Output is correct
34 Correct 2 ms 3796 KB Output is correct
35 Correct 3 ms 3796 KB Output is correct
36 Correct 3 ms 3796 KB Output is correct
37 Correct 3 ms 3736 KB Output is correct
38 Correct 5 ms 3796 KB Output is correct
39 Correct 3 ms 3796 KB Output is correct
40 Correct 4 ms 3796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
9 Correct 2 ms 3412 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 2 ms 3412 KB Output is correct
12 Correct 2 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 3 ms 3412 KB Output is correct
15 Correct 3 ms 3412 KB Output is correct
16 Correct 3 ms 3412 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 2 ms 3412 KB Output is correct
21 Correct 2 ms 3412 KB Output is correct
22 Correct 2 ms 3412 KB Output is correct
23 Correct 3 ms 3796 KB Output is correct
24 Correct 4 ms 3796 KB Output is correct
25 Correct 3 ms 3796 KB Output is correct
26 Correct 3 ms 3796 KB Output is correct
27 Correct 2 ms 3796 KB Output is correct
28 Correct 3 ms 3796 KB Output is correct
29 Correct 3 ms 3796 KB Output is correct
30 Correct 3 ms 3796 KB Output is correct
31 Correct 3 ms 3796 KB Output is correct
32 Correct 3 ms 3796 KB Output is correct
33 Correct 2 ms 3796 KB Output is correct
34 Correct 2 ms 3796 KB Output is correct
35 Correct 3 ms 3796 KB Output is correct
36 Correct 3 ms 3796 KB Output is correct
37 Correct 3 ms 3736 KB Output is correct
38 Correct 5 ms 3796 KB Output is correct
39 Correct 3 ms 3796 KB Output is correct
40 Correct 4 ms 3796 KB Output is correct
41 Correct 24 ms 5676 KB Output is correct
42 Incorrect 21 ms 5836 KB Output isn't correct
43 Halted 0 ms 0 KB -