QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#795017#7963. 多折较差验证thelongXiao#WA 13ms10764kbPython3727b2024-11-30 17:27:312024-11-30 17:27:31

Judging History

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

  • [2024-11-30 17:27:31]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:10764kb
  • [2024-11-30 17:27:31]
  • 提交

answer

def main():
    n = int(input())
    s = input()
    v_count = [0] * (n + 1)
    for i in range(n):
        if s[i] == 'v':
            v_count[i + 1] = v_count[i] + 1
        else:
            v_count[i + 1] = v_count[i] - 1

    max_sub = [0] * (n + 1)
    max_sum = 0
    sum = 0
    for i in range(n + 1):
        max_sum = max(max_sum, sum)
        max_sub[i] = max_sum
        sum += v_count[i]
        if sum < 0:
            sum = 0

    fold_count = n - 1
    elm = 0
    for i in range(n):
        if s[i] == 'v':
            elm += max_sub[-1] - max_sub[i + 1]
        else:
            elm += max_sub[i] - max_sub[-1]

    print(fold_count, elm)

if __name__ == "__main__":
    main()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 13ms
memory: 10764kb

input:

5000
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

output:

4999 0

result:

wrong answer 1st lines differ - expected: '5000 12497500', found: '4999 0'