QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#358287#407. ToiletsAMongus21370 1ms3832kbC++20815b2024-03-19 18:47:302024-03-19 18:47:31

Judging History

你现在查看的是最新测评结果

  • [2024-03-19 18:47:31]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3832kb
  • [2024-03-19 18:47:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;

int main()
{
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  ll minn = -1, dif = 0;
  for (int c, i = 0; i < m; i++)
  {
    string s;
    cin >> s >> c;

    ll subdif = 0, submin = 0;
    for (auto z : s)
    {
      subdif += (z == 'M' ? 1LL : -1LL);
      submin = min(submin, subdif);
    }
    ll totmin = 0;
    if (subdif < 0)
    {
      totmin = subdif * (c - 1);
    }
    totmin += submin;
    minn = min(minn, dif + totmin);

    dif += subdif * c;
  }

  if (dif > 0)
  {
    cout << "źle1\n";
    cout << "-1\n";
    return 0;
  }

  cout << max(0LL, dif - (minn + 1)) << "\n";
}

/*
2 1
FFMF 1

6 1
MFFFMFMMFFFM 1

6 1
FFFMMMMMMFFF 1

6 3
F 3
M 6
F 3
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 14
Accepted
time: 1ms
memory: 3776kb

input:

10
1
FMFFFFFFMFFFMMMMMFMM 1

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

10
1
FFMFMMFFFFMMMFMMMMFF 1

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

10
1
MFMMFFFMMFFMMMMFFFFF 1

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

10
1
FMFMFFMFMFMMFFMFMFMM 1

output:

1

result:

ok single line: '1'

Test #5:

score: -14
Wrong Answer
time: 0ms
memory: 3812kb

input:

10
1
MFFFMFMMMMMMMMMFMFFM 1

output:

źle1
-1

result:

wrong answer 1st lines differ - expected: '-1', found: 'źle1'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%